E1 (herd-vs-stranding discrimination) sweeps smarm scheduler count at fixed low concurrency. Strict parse — a malformed value panics instead of silently reverting to default, and the effective value is logged to stderr so every bench cell's server.log records it (same per-cell verification discipline as mode-verify).
49 lines
2.1 KiB
Rust
49 lines
2.1 KiB
Rust
//! Plain benchmark server: the `load_profile` request path with zero causal
|
|
//! machinery — the baseline half of the ka/close A/B matrix (the
|
|
//! throughput-inversion chase).
|
|
//!
|
|
//! Identical route, handler, and `Config` construction to `load_profile`;
|
|
//! differs only in having no `smarm-causal` feature, no sweep, and no
|
|
//! shutdown path — it serves until killed. Throughput is measured
|
|
//! externally (wrk).
|
|
//!
|
|
//! Env:
|
|
//! URUS_PORT listen port (default 8080; binds 0.0.0.0)
|
|
//! URUS_SCHED_THREADS smarm scheduler OS threads (default: smarm's own
|
|
//! default). Malformed values panic rather than
|
|
//! silently falling back — a benchmark knob that
|
|
//! quietly reverts to default poisons the cell.
|
|
//!
|
|
//! cargo run --release --example plain_serve
|
|
|
|
use std::net::SocketAddr;
|
|
|
|
use urus::{serve_with, Config, Conn, Next, Pipeline, Router};
|
|
|
|
/// Mirrors `load_profile`'s handler byte for byte: param parse + JSON render.
|
|
fn json_id(conn: Conn, _next: Next) -> Conn {
|
|
let id: u64 = conn.params.get("id").and_then(|s| s.parse().ok()).unwrap_or(0);
|
|
conn.put_status(200)
|
|
.put_header("content-type", "application/json")
|
|
.put_body(format!("{{\"id\":{id}}}"))
|
|
}
|
|
|
|
fn main() {
|
|
let port: u16 = std::env::var("URUS_PORT")
|
|
.ok()
|
|
.and_then(|v| v.parse().ok())
|
|
.unwrap_or(8080);
|
|
let addr: SocketAddr = format!("0.0.0.0:{port}").parse().expect("addr");
|
|
let sched_threads: Option<usize> = std::env::var("URUS_SCHED_THREADS").ok().map(|v| {
|
|
v.parse()
|
|
.unwrap_or_else(|_| panic!("URUS_SCHED_THREADS not a usize: {v:?}"))
|
|
});
|
|
// Audit line: lands in each bench cell's server.log so the effective
|
|
// scheduler count is recorded per cell, same discipline as mode-verify.
|
|
eprintln!("plain_serve: scheduler_threads={sched_threads:?}");
|
|
let mut cfg = Config::new(addr);
|
|
cfg.scheduler_threads = sched_threads;
|
|
let pipe = Pipeline::new().plug(Router::new().get("/json/:id", json_id));
|
|
serve_with(cfg, pipe).expect("serve");
|
|
}
|