Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/benchmarks-mv/blob/main/src/harness/mod.rs # benchmarks-mv Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `benchmarks-mv / src / harness / mod.rs` 310 lines ยท 12039 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 pub mod http_bench; 17 pub mod inference_bench; 18 pub mod llm_stream; 19 pub mod memory; 20 pub mod smaps; 21 pub mod sse; 22 pub mod standalone; 23 pub mod system; 24 pub mod workloads; 25 26 use crate::models::{BenchmarkData, LatencyMetric, MemoryMetric, NeuralMetric}; 27 use std::time::Instant; 28 29 pub struct MeasurementConfig { 30 pub concurrency: u32, 31 pub requests: u32, 32 pub warmup: u32, 33 pub skip_standalone: bool, 34 pub skip_live: bool, 35 /// Streaming LLM endpoint to measure; None skips it. 36 pub llm: Option, 37 } 38 39 impl Default for MeasurementConfig { 40 fn default() -> Self { 41 Self { 42 concurrency: 10, 43 requests: 500, 44 warmup: 20, 45 skip_standalone: false, 46 skip_live: false, 47 llm: Some(llm_stream::StreamConfig::default()), 48 } 49 } 50 } 51 52 pub fn run_measurement_suite(config: MeasurementConfig) -> Result { 53 println!("=== AIEN Sovereign Benchmark Suite: Active Measurement Sweep ==="); 54 let sweep_start = Instant::now(); 55 56 // 1. Detect System Hardware and Environment 57 println!(" [1/4] Detecting system hardware and execution environment..."); 58 let hardware = system::detect_hardware(); 59 let environment = 60 system::detect_environment(config.concurrency, config.requests, config.warmup); 61 println!( 62 " Target: {} ({}) | OS: {}", 63 hardware.system, hardware.processor, hardware.os 64 ); 65 println!(" Compiler: {}", environment.rustc_version); 66 67 let mut memory_rss: Vec = Vec::new(); 68 let mut latency_concurrency: Vec = Vec::new(); 69 70 // 2. Standalone Rust microservice benchmarks (our own server, measured on its own) 71 if !config.skip_standalone { 72 println!(" [2/4] Executing standalone native Rust microservice benchmarks..."); 73 74 let rust_server = standalone::RustStandaloneServer::start() 75 .map_err(|e| format!("Rust standalone start error: {}", e))?; 76 println!( 77 " Rust Standalone Server active on port {}", 78 rust_server.port 79 ); 80 81 let endpoints = [ 82 ( 83 "BENCH-LIVE-STANDALONE-STATUS-001", 84 "/api/status", 85 "Minimal JSON Status Ping", 86 "Rust Standalone (Native Compiled)", 87 ), 88 ( 89 "BENCH-LIVE-STANDALONE-QUERY-001", 90 "/api/query", 91 "Single Entity Query & JSON Serialization", 92 "Rust Standalone (Native Compiled)", 93 ), 94 ( 95 "BENCH-LIVE-STANDALONE-VEC-001", 96 "/api/vector", 97 "768-dimensional Vector Dot Product", 98 "Rust SIMD Vector Loop", 99 ), 100 ]; 101 for (id, endpoint, description, engine) in endpoints { 102 let bench = http_bench::run_http_benchmark( 103 "127.0.0.1", 104 rust_server.port, 105 endpoint, 106 None, 107 config.concurrency as usize, 108 config.requests as usize, 109 config.warmup as usize, 110 )?; 111 println!( 112 " {}: p50 {:.2} ms ({:.0} req/s)", 113 description, bench.p50_ms, bench.requests_per_sec 114 ); 115 latency_concurrency.push(LatencyMetric { 116 measurement_id: Some(id.to_string()), 117 service: "rust-standalone".to_string(), 118 endpoint: endpoint.to_string(), 119 description: description.to_string(), 120 engine: engine.to_string(), 121 requests_per_sec: bench.requests_per_sec, 122 p50_ms: bench.p50_ms, 123 p95_ms: bench.p95_ms, 124 p99_ms: bench.p99_ms, 125 concurrency: config.concurrency, 126 sample_size: bench.total_requests as u32, 127 }); 128 } 129 } 130 131 // 3. Inspect Live Sovereign Services 132 if !config.skip_live { 133 println!(" [3/4] Inspecting active sovereign background services..."); 134 135 // aegis-runtime 136 if let Some(aegis_pid) = memory::find_pid_by_pattern("aegis") { 137 if let Some(aegis_rss) = memory::read_process_rss_mb(aegis_pid) { 138 memory_rss.push(MemoryMetric { 139 measurement_id: Some("BENCH-LIVE-AEGIS-RSS-001".to_string()), 140 service: "aegis-runtime".to_string(), 141 role: "Sovereign Gateway & Heartbeat".to_string(), 142 architecture: "Native Rust (Grace Blackwell)".to_string(), 143 rss_mb: aegis_rss, 144 }); 145 } 146 } 147 148 // cortex-rs 149 if let Some(cortex_pid) = memory::find_pid_by_pattern("cortex-rs") { 150 if let Some(cortex_rss) = memory::read_process_rss_mb(cortex_pid) { 151 memory_rss.push(MemoryMetric { 152 measurement_id: Some("BENCH-LIVE-CORTEX-RSS-001".to_string()), 153 service: "cortex-rs".to_string(), 154 role: "Canonical Memory Engine".to_string(), 155 architecture: "Native Rust + SQLite WAL".to_string(), 156 rss_mb: cortex_rss, 157 }); 158 } 159 } 160 161 // spark-cockpit-rs 162 if let Some(cockpit_pid) = memory::find_pid_by_pattern("spark-cockpit-rs") { 163 if let Some(cockpit_rss) = memory::read_process_rss_mb(cockpit_pid) { 164 memory_rss.push(MemoryMetric { 165 measurement_id: Some("BENCH-LIVE-COCKPIT-RSS-001".to_string()), 166 service: "spark-cockpit-rs".to_string(), 167 role: "Real-time Telemetry Cockpit".to_string(), 168 architecture: "Native Rust + Axum".to_string(), 169 rss_mb: cockpit_rss, 170 }); 171 } 172 } 173 174 // cortex-encoder-rs 175 if let Some(encoder_pid) = memory::find_pid_by_pattern("cortex-encoder-rs") { 176 if let Some(encoder_rss) = memory::read_process_rss_mb(encoder_pid) { 177 memory_rss.push(MemoryMetric { 178 measurement_id: Some("BENCH-LIVE-ENCODER-RSS-001".to_string()), 179 service: "cortex-encoder-rs".to_string(), 180 role: "Neural Embedding Microservice".to_string(), 181 architecture: "Rust + ONNX Runtime (BGE-M3)".to_string(), 182 rss_mb: encoder_rss, 183 }); 184 } 185 } 186 187 // Benchmark live HTTP endpoints 188 if let Ok(bench) = http_bench::run_http_benchmark( 189 "127.0.0.1", 190 18080, 191 "/api/cortex/get", 192 None, 193 config.concurrency as usize, 194 config.requests as usize, 195 config.warmup as usize, 196 ) { 197 latency_concurrency.push(LatencyMetric { 198 measurement_id: Some("BENCH-LIVE-CORTEX-GET-001".to_string()), 199 service: "cortex-rs".to_string(), 200 endpoint: "/api/cortex/get".to_string(), 201 description: "Cortex Canonical Retrieval".to_string(), 202 engine: "Rust Axum + SQLite WAL".to_string(), 203 requests_per_sec: bench.requests_per_sec, 204 p50_ms: bench.p50_ms, 205 p95_ms: bench.p95_ms, 206 p99_ms: bench.p99_ms, 207 concurrency: config.concurrency, 208 sample_size: bench.total_requests as u32, 209 }); 210 } 211 212 if let Ok(bench) = http_bench::run_http_benchmark( 213 "127.0.0.1", 214 18095, 215 "/api/pulse", 216 None, 217 config.concurrency as usize, 218 config.requests as usize, 219 config.warmup as usize, 220 ) { 221 latency_concurrency.push(LatencyMetric { 222 measurement_id: Some("BENCH-LIVE-PULSE-001".to_string()), 223 service: "spark-cockpit-rs".to_string(), 224 endpoint: "/api/pulse".to_string(), 225 description: "Real-time System Pulse".to_string(), 226 engine: "Rust Axum".to_string(), 227 requests_per_sec: bench.requests_per_sec, 228 p50_ms: bench.p50_ms, 229 p95_ms: bench.p95_ms, 230 p99_ms: bench.p99_ms, 231 concurrency: config.concurrency, 232 sample_size: bench.total_requests as u32, 233 }); 234 } 235 236 if let Ok(bench) = http_bench::run_http_benchmark( 237 "127.0.0.1", 238 18081, 239 "/health", 240 None, 241 config.concurrency as usize, 242 config.requests as usize, 243 config.warmup as usize, 244 ) { 245 latency_concurrency.push(LatencyMetric { 246 measurement_id: Some("BENCH-LIVE-ENCODER-HEALTH-001".to_string()), 247 service: "cortex-encoder-rs".to_string(), 248 endpoint: "/health".to_string(), 249 description: "ONNX Runtime Service Health".to_string(), 250 engine: "Rust Axum + ONNX Runtime".to_string(), 251 requests_per_sec: bench.requests_per_sec, 252 p50_ms: bench.p50_ms, 253 p95_ms: bench.p95_ms, 254 p99_ms: bench.p99_ms, 255 concurrency: config.concurrency, 256 sample_size: bench.total_requests as u32, 257 }); 258 } 259 } 260 261 // 4. In-Memory Neural and SIMD Vector Benchmarks 262 println!(" [4/4] Recording neural inference and SIMD compute metrics..."); 263 let mut neural_inference = 264 inference_bench::run_neural_inference_benchmarks(config.llm.as_ref()); 265 266 let simd_bench = workloads::run_vector_dot_product_benchmark(100_000, 768); 267 println!( 268 " SIMD Vector Dot Product (768-dim x 100,000 iter): {:.2} ms ({:.0} ops/s, {:.3} us/op)", 269 simd_bench.elapsed_ms, simd_bench.operations_per_sec, simd_bench.p50_latency_us 270 ); 271 neural_inference.push(NeuralMetric { 272 measurement_id: Some("BENCH-LIVE-SIMD-DOT-001".to_string()), 273 workload: "SIMD Vector Dot Product (768-dim)".to_string(), 274 model: "In-Memory Cortex Embedding".to_string(), 275 engine: "Rust SIMD Vector Loop".to_string(), 276 p50_ms: simd_bench.p50_latency_us / 1000.0, 277 // The loop yields one mean per iteration, not a distribution: no p95 exists. 278 p95_ms: None, 279 }); 280 281 let total_elapsed = sweep_start.elapsed(); 282 println!( 283 "=== Active Measurement Sweep Complete in {:.2}s ===\n", 284 total_elapsed.as_secs_f64() 285 ); 286 287 let timestamp = std::process::Command::new("date") 288 .args(["-u", "+%Y-%m-%dT%H:%M:%SZ"]) 289 .output() 290 .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) 291 .unwrap_or_else(|_| "2026-09-19T07:20:00Z".to_string()); 292 293 Ok(BenchmarkData { 294 benchmark_suite: "AIEN Sovereign Systems Performance Benchmark Suite".to_string(), 295 version: "0.2.0".to_string(), 296 schema_version: Some("1.0.0".to_string()), 297 benchmark_commit: None, 298 core_commit: None, 299 timestamp, 300 hardware, 301 environment, 302 memory_rss, 303 latency_concurrency, 304 neural_inference, 305 concurrency_pressure: Vec::new(), 306 context_scaling: Vec::new(), 307 multi_model_breadth: Vec::new(), 308 cross_surface: Vec::new(), 309 }) 310 }