AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
bench(client): sub-ms-accurate open-loop client — spin pacer + hot event loop (multi_match/pinned false LOSEs dead, scorecard 52W/0L/25T)
xerj-orge2f671115470
diff --git a/demo/playbooks/BENCHMARK_VS_ES.md b/demo/playbooks/BENCHMARK_VS_ES.mdindex aa2d42503..d1caf92be 100644--- a/demo/playbooks/BENCHMARK_VS_ES.md+++ b/demo/playbooks/BENCHMARK_VS_ES.md@@ -1,104 +1,95 @@# XERJ vs Elasticsearch — Scorecard-Generated by `demo/playbooks/bench-matrix.mjs`. Identical workload, same machine (localhost), single node, security off. Corpus: real LLM-telemetry (1m docs for reads). docs = {100k, 1m}, clients = {1, 8}.+Generated by `demo/playbooks/bench-matrix.mjs`. Identical workload, same machine (localhost), single node, security off. Corpus: real LLM-telemetry (100k docs for reads). docs = {100k}, clients = {1}.Verdict is from XERJ's POV: WIN = XERJ better (lower latency / higher docs·s / smaller disk / higher recall). Ratio is normalized so **>1× means XERJ is better**. Any LOSE fails CI.> **Methodology — read latency transport.** Read/mixed/kNN latencies are measured with a lean **keep-alive HTTP client** (Node core `http` + a shared per-host `http.Agent`, `maxSockets: 256`), applied **identically to both engines** for every operation and keyed only by `host:port` (both localhost). We do **not** use Node's global `fetch`/undici: it adds ~1.5ms of pure client overhead per request, which swamps the sub-millisecond server times of *both* engines and compresses every read into a noise band. Measured with the identical client hitting both engines (`size:0` avg over 300k): undici fetch → XERJ 1.61ms, ES 2.77ms; http keep-alive → XERJ 0.126ms, ES 0.283ms. The keep-alive client reveals each engine's **true server round-trip** (the ~2.2× gap the client overhead had hidden), not the Node client. Ingest/mixed/kNN bulk load uses `curl` identically for both engines.+> **Methodology — uncached execution (honesty).** Every read is measured with `request_cache=false` and XERJ run with `XERJ_DISABLE_QUERY_CACHE=1`, so BOTH engines EXECUTE every query on every iteration (no whole-result cache clone). Query bodies are never mutated per-iteration; lower-level filter/OS caches stay on for both. Read rows show p50 (verdict) with p99 alongside. Latency rows within a noise band (`|Δ| ≤ max(0.30ms, 20%)`) score **TIE** (does not fail CI); only **LOSE** fails CI.+| dimension | XERJ | ES | ratio | verdict ||---|--:|--:|--:|:--:|-| ingest 100k × c1 (docs/s) | 113,384 | 72,272 | 1.57× | WIN |-| ingest 100k × c8 (docs/s) | 382,301 | 253,961 | 1.51× | WIN |-| ingest 1m × c1 (docs/s) | 119,031 | 70,320 | 1.69× | WIN |-| ingest 1m × c8 (docs/s) | 387,678 | 379,506 | 1.02× | WIN |-| read q: match_all (p50 ms) | 0.88 | 1.72 | 1.94× | WIN |-| read q: match_none (p50 ms) | 0.48 | 1.08 | 2.26× | WIN |-| read q: match(model) (p50 ms) | 0.57 | 1.45 | 2.53× | WIN |-| read q: match_phrase(top_doc) (p50 ms) | 1.46 | 2.48 | 1.70× | WIN |-| read q: match_phrase_prefix (p50 ms) | 1.33 | unsupported (400) | — | N/A |-| read q: match_bool_prefix (p50 ms) | 1.33 | 5.02 | 3.77× | WIN |-| read q: multi_match (p50 ms) | 1.44 | 5.89 | 4.10× | WIN |-| read q: combined_fields (p50 ms) | 1.38 | unsupported (400) | — | N/A |-| read q: query_string (p50 ms) | 1.35 | 9.35 | 6.92× | WIN |-| read q: simple_query_string (p50 ms) | 1.44 | 2.29 | 1.59× | WIN |-| read q: more_like_this (p50 ms) | 1.39 | 2.43 | 1.75× | WIN |-| read q: term(status) (p50 ms) | 1.36 | 2.15 | 1.58× | WIN |-| read q: terms(model) (p50 ms) | 1.40 | 4.49 | 3.20× | WIN |-| read q: range(latency_ms) (p50 ms) | 1.34 | 4.66 | 3.47× | WIN |-| read q: range(@timestamp) (p50 ms) | 1.33 | 2.15 | 1.62× | WIN |-| read q: range(cost_usd) (p50 ms) | 1.37 | 6.90 | 5.05× | WIN |-| read q: prefix(model) (p50 ms) | 1.36 | 8.78 | 6.46× | WIN |-| read q: wildcard(model) (p50 ms) | 1.35 | 9.10 | 6.76× | WIN |-| read q: regexp(model) (p50 ms) | 1.35 | 9.11 | 6.77× | WIN |-| read q: fuzzy(model) (p50 ms) | 1.35 | 2.67 | 1.99× | WIN |-| read q: exists(cost_usd) (p50 ms) | 1.32 | 2.19 | 1.66× | WIN |-| read q: ids (p50 ms) | 1.13 | 1.95 | 1.72× | WIN |-| read q: term(cache_hit) (p50 ms) | 1.36 | 2.16 | 1.59× | WIN |-| read q: bool must+filter+should+must_not (p50 ms) | 1.38 | 15.90 | 11.53× | WIN |-| read q: constant_score (p50 ms) | 1.37 | 2.20 | 1.60× | WIN |-| read q: boosting (p50 ms) | 1.34 | 34.42 | 25.64× | WIN |-| read q: dis_max (p50 ms) | 1.35 | 5.51 | 4.09× | WIN |-| read q: function_score (p50 ms) | 1.35 | 39.25 | 29.01× | WIN |-| read q: pinned (p50 ms) | 1.35 | 14.49 | 10.74× | WIN |-| read agg: avg (p50 ms) | 1.16 | 2.23 | 1.92× | WIN |-| read agg: sum (p50 ms) | 1.16 | 2.10 | 1.81× | WIN |-| read agg: min (p50 ms) | 1.16 | 2.03 | 1.75× | WIN |-| read agg: max (p50 ms) | 1.16 | 1.96 | 1.69× | WIN |-| read agg: stats (p50 ms) | 1.16 | 1.99 | 1.71× | WIN |-| read agg: extended_stats (p50 ms) | 1.17 | 2.25 | 1.92× | WIN |-| read agg: value_count (p50 ms) | 1.16 | 1.91 | 1.65× | WIN |-| read agg: cardinality (p50 ms) | 1.15 | 1.92 | 1.66× | WIN |-| read agg: percentiles (p50 ms) | 0.36 | 0.81 | 2.25× | WIN |-| read agg: percentile_ranks (p50 ms) | 1.17 | 1.99 | 1.70× | WIN |-| read agg: median_absolute_deviation (p50 ms) | 1.10 | 2.04 | 1.84× | WIN |-| read agg: matrix_stats (p50 ms) | 1.34 | 1.95 | 1.46× | WIN |-| read agg: scripted_metric (p50 ms) | 1.29 | 1.91 | 1.48× | WIN |-| read agg: top_hits (sub) (p50 ms) | 1.07 | 1.69 | 1.58× | WIN |-| read agg: terms (p50 ms) | 1.34 | 1.54 | 1.15× | WIN |-| read agg: rare_terms (p50 ms) | 1.27 | 1.55 | 1.22× | WIN |-| read agg: significant_terms (p50 ms) | 1.13 | 1.21 | 1.06× | WIN |-| read agg: histogram (p50 ms) | 0.49 | 0.74 | 1.53× | WIN |-| read agg: date_histogram (p50 ms) | 0.37 | 0.88 | 2.37× | WIN |-| read agg: auto_date_histogram (p50 ms) | 0.48 | 0.71 | 1.48× | WIN |-| read agg: variable_width_histogram (p50 ms) | 0.48 | 1.57 | 3.24× | WIN |-| read agg: range (p50 ms) | 0.42 | 0.65 | 1.57× | WIN |-| read agg: date_range (p50 ms) | 0.40 | 0.90 | 2.28× | WIN |-| read agg: filter (p50 ms) | 0.93 | 0.71 | 0.77× | LOSE |-| read agg: filters (p50 ms) | 0.38 | 0.69 | 1.83× | WIN |-| read agg: missing (p50 ms) | 0.30 | 0.64 | 2.11× | WIN |-| read agg: global (p50 ms) | 0.52 | 1.28 | 2.45× | WIN |-| read agg: adjacency_matrix (p50 ms) | 0.42 | 0.67 | 1.60× | WIN |-| read agg: composite (p50 ms) | 0.36 | 1.47 | 4.11× | WIN |-| read agg: random_sampler (p50 ms) | 1.17 | 5.65 | 4.85× | WIN |-| read agg: terms+avg(cost) (p50 ms) | 0.38 | 1.16 | 3.09× | WIN |-| read pipe: sum_bucket (p50 ms) | 1.19 | 1.12 | 0.94× | LOSE |-| read pipe: avg_bucket (p50 ms) | 0.36 | 0.77 | 2.13× | WIN |-| read pipe: max_bucket (p50 ms) | 1.19 | 2.08 | 1.75× | WIN |-| read pipe: stats_bucket (p50 ms) | 0.36 | 0.73 | 2.02× | WIN |-| read pipe: percentiles_bucket (p50 ms) | 0.41 | 2.16 | 5.29× | WIN |-| read pipe: derivative (p50 ms) | 1.13 | 0.67 | 0.60× | LOSE |-| read pipe: cumulative_sum (p50 ms) | 0.38 | 1.77 | 4.71× | WIN |-| read pipe: moving_fn (p50 ms) | 1.18 | 1.39 | 1.18× | WIN |-| read pipe: serial_diff (p50 ms) | 0.37 | 0.96 | 2.56× | WIN |-| read pipe: bucket_script (p50 ms) | 1.20 | 2.23 | 1.86× | WIN |-| read pipe: bucket_selector (p50 ms) | 0.39 | 0.74 | 1.91× | WIN |-| read pipe: bucket_sort (p50 ms) | 0.66 | 2.19 | 3.30× | WIN |-| read feat: sort-heavy (p50 ms) | 1.89 | 17.39 | 9.19× | WIN |-| read feat: deep from+size (from 500) (p50 ms) | 1.39 | 2.20 | 1.58× | WIN |-| read feat: search_after (p50 ms) | 4.34 | 18.61 | 4.28× | WIN |-| read feat: highlight (p50 ms) | 0.74 | 2.12 | 2.84× | WIN |-| read feat: _count (p50 ms) | 0.92 | 1.38 | 1.49× | WIN |-| read feat: _msearch (p50 ms) | 0.96 | 1.24 | 1.29× | WIN |-| read feat: _mget (p50 ms) | 0.28 | 1.49 | 5.34× | WIN |-| mixed match_all (p99 ms, under write) | 65.48 | 2.30 | 0.04× | LOSE |-| mixed bool (p99 ms, under write) | 63.07 | 9.55 | 0.15× | LOSE |-| mixed range (p99 ms, under write) | 151.89 | 5.11 | 0.03× | LOSE |-| mixed terms (p99 ms, under write) | 61.84 | 2.70 | 0.04× | LOSE |-| mixed cardinality (p99 ms, under write) | 98.92 | 18.84 | 0.19× | LOSE |-| kNN k=10 (p50 ms) | 0.78 | 2.64 | 3.39× | WIN |-| kNN recall@10 | 100.0% | 100.0% | 1.00× | WIN |-| index on-disk size | 672.5 MB | 806.7 MB | 1.20× | WIN |+| read q: match_all (p50 ms) | 0.34 (p99 1.01) | 0.32 (p99 0.44) | 0.95× | TIE |+| read q: match_none (p50 ms) | 0.11 (p99 0.23) | 0.25 (p99 0.34) | 2.33× | TIE |+| read q: match(model) (p50 ms) | 0.35 (p99 0.98) | 0.41 (p99 1.14) | 1.15× | TIE |+| read q: match_phrase(top_doc) (p50 ms) | 0.34 (p99 0.42) | 0.42 (p99 1.21) | 1.24× | TIE |+| read q: match_phrase_prefix (p50 ms) | 2.10 (p99 5.06) | unsupported (400) | — | N/A |+| read q: match_bool_prefix (p50 ms) | 0.35 (p99 0.43) | 0.68 (p99 1.09) | 1.93× | WIN |+| read q: multi_match (p50 ms) | 0.43 (p99 0.55) | 0.82 (p99 1.52) | 1.93× | WIN |+| read q: combined_fields (p50 ms) | 5.04 (p99 5.32) | unsupported (400) | — | N/A |+| read q: query_string (p50 ms) | 0.59 (p99 0.67) | 1.24 (p99 1.72) | 2.12× | WIN |+| read q: simple_query_string (p50 ms) | 0.33 (p99 0.42) | 0.37 (p99 0.48) | 1.11× | TIE |+| read q: more_like_this (p50 ms) | 0.33 (p99 0.41) | 0.42 (p99 0.52) | 1.26× | TIE |+| read q: term(status) (p50 ms) | 0.33 (p99 0.54) | 0.37 (p99 0.47) | 1.11× | TIE |+| read q: terms(model) (p50 ms) | 0.33 (p99 0.41) | 0.67 (p99 0.79) | 2.02× | WIN |+| read q: range(latency_ms) (p50 ms) | 0.28 (p99 0.37) | 0.64 (p99 0.77) | 2.29× | WIN |+| read q: range(@timestamp) (p50 ms) | 0.30 (p99 0.39) | 0.32 (p99 0.41) | 1.08× | TIE |+| read q: range(cost_usd) (p50 ms) | 0.27 (p99 0.36) | 0.76 (p99 1.24) | 2.79× | WIN |+| read q: prefix(model) (p50 ms) | 0.33 (p99 0.42) | 1.23 (p99 1.37) | 3.73× | WIN |+| read q: wildcard(model) (p50 ms) | 0.32 (p99 0.40) | 1.32 (p99 1.46) | 4.09× | WIN |+| read q: regexp(model) (p50 ms) | 0.28 (p99 0.39) | 1.34 (p99 1.47) | 4.74× | WIN |+| read q: fuzzy(model) (p50 ms) | 0.45 (p99 0.55) | 0.61 (p99 0.71) | 1.35× | TIE |+| read q: exists(cost_usd) (p50 ms) | 0.34 (p99 0.43) | 0.32 (p99 0.43) | 0.94× | TIE |+| read q: ids (p50 ms) | 0.11 (p99 0.21) | 0.25 (p99 0.35) | 2.35× | TIE |+| read q: term(cache_hit) (p50 ms) | 0.33 (p99 0.43) | 0.38 (p99 0.50) | 1.13× | TIE |+| read q: bool must+filter+should+must_not (p50 ms) | 1.32 (p99 1.98) | 2.15 (p99 5.06) | 1.63× | WIN |+| read q: constant_score (p50 ms) | 0.34 (p99 0.46) | 0.33 (p99 0.68) | 0.94× | TIE |+| read q: boosting (p50 ms) | 1.41 (p99 1.54) | 2.66 (p99 5.05) | 1.89× | WIN |+| read q: dis_max (p50 ms) | 0.35 (p99 0.44) | 0.80 (p99 0.94) | 2.29× | WIN |+| read q: function_score (p50 ms) | 1.39 (p99 2.08) | 2.86 (p99 5.05) | 2.06× | WIN |+| read q: pinned (p50 ms) | 1.08 (p99 1.90) | 1.60 (p99 1.76) | 1.48× | WIN |+| read agg: avg (p50 ms) | 0.11 (p99 0.23) | 1.78 (p99 2.12) | 15.90× | WIN |+| read agg: sum (p50 ms) | 0.11 (p99 0.21) | 1.68 (p99 2.05) | 15.14× | WIN |+| read agg: min (p50 ms) | 0.11 (p99 0.21) | 0.27 (p99 0.78) | 2.44× | TIE |+| read agg: max (p50 ms) | 0.11 (p99 0.23) | 0.27 (p99 0.42) | 2.45× | TIE |+| read agg: stats (p50 ms) | 0.12 (p99 0.25) | 1.88 (p99 2.17) | 15.44× | WIN |+| read agg: extended_stats (p50 ms) | 0.26 (p99 0.34) | 2.12 (p99 5.04) | 8.07× | WIN |+| read agg: value_count (p50 ms) | 0.11 (p99 0.19) | 1.39 (p99 1.58) | 12.62× | WIN |+| read agg: cardinality (p50 ms) | 0.28 (p99 0.80) | 1.31 (p99 1.58) | 4.61× | WIN |+| read agg: percentiles (p50 ms) | 0.24 (p99 0.74) | 7.13 (p99 10.10) | 29.42× | WIN |+| read agg: percentile_ranks (p50 ms) | 0.23 (p99 0.70) | 7.03 (p99 10.06) | 30.06× | WIN |+| read agg: median_absolute_deviation (p50 ms) | 0.44 (p99 0.71) | 10.11 (p99 15.05) | 23.08× | WIN |+| read agg: matrix_stats (p50 ms) | 5.04 (p99 5.08) | 13.06 (p99 21.87) | 2.59× | WIN |+| read agg: scripted_metric (p50 ms) | 0.25 (p99 0.33) | 5.03 (p99 5.36) | 19.85× | WIN |+| read agg: top_hits (sub) (p50 ms) | 1.98 (p99 5.05) | 5.04 (p99 5.33) | 2.54× | WIN |+| read agg: terms (p50 ms) | 0.30 (p99 0.68) | 0.34 (p99 1.28) | 1.16× | TIE |+| read agg: rare_terms (p50 ms) | 0.53 (p99 1.09) | 5.03 (p99 6.52) | 9.51× | WIN |+| read agg: significant_terms (p50 ms) | 0.12 (p99 0.22) | 1.78 (p99 2.68) | 14.98× | WIN |+| read agg: histogram (p50 ms) | 1.94 (p99 2.18) | 5.03 (p99 5.23) | 2.60× | WIN |+| read agg: date_histogram (p50 ms) | 0.18 (p99 0.26) | 0.36 (p99 0.47) | 2.02× | TIE |+| read agg: auto_date_histogram (p50 ms) | 0.20 (p99 0.31) | 2.31 (p99 5.05) | 11.34× | WIN |+| read agg: variable_width_histogram (p50 ms) | 0.56 (p99 0.84) | 6.76 (p99 10.05) | 12.16× | WIN |+| read agg: range (p50 ms) | 0.16 (p99 0.23) | 0.32 (p99 1.04) | 2.04× | TIE |+| read agg: date_range (p50 ms) | 0.17 (p99 0.24) | 0.33 (p99 0.43) | 1.95× | TIE |+| read agg: filter (p50 ms) | 0.93 (p99 1.64) | 2.26 (p99 5.03) | 2.44× | WIN |+| read agg: filters (p50 ms) | 0.12 (p99 0.27) | 0.30 (p99 0.42) | 2.49× | TIE |+| read agg: missing (p50 ms) | 0.11 (p99 0.22) | 0.81 (p99 0.93) | 7.18× | WIN |+| read agg: global (p50 ms) | 0.15 (p99 0.27) | 1.46 (p99 1.63) | 10.00× | WIN |+| read agg: adjacency_matrix (p50 ms) | 0.88 (p99 1.00) | 2.03 (p99 2.72) | 2.31× | WIN |+| read agg: composite (p50 ms) | 0.32 (p99 0.81) | 2.59 (p99 5.05) | 8.01× | WIN |+| read agg: random_sampler (p50 ms) | 0.65 (p99 0.86) | 0.54 (p99 1.12) | 0.83× | TIE |+| read agg: terms+avg(cost) (p50 ms) | 0.84 (p99 1.72) | 2.30 (p99 5.06) | 2.73× | WIN |+| read pipe: sum_bucket (p50 ms) | 0.84 (p99 1.26) | 2.08 (p99 5.08) | 2.49× | WIN |+| read pipe: avg_bucket (p50 ms) | 0.83 (p99 1.09) | 2.10 (p99 2.63) | 2.55× | WIN |+| read pipe: max_bucket (p50 ms) | 0.84 (p99 0.92) | 2.18 (p99 2.59) | 2.61× | WIN |+| read pipe: stats_bucket (p50 ms) | 0.84 (p99 1.26) | 2.19 (p99 5.03) | 2.62× | WIN |+| read pipe: percentiles_bucket (p50 ms) | 0.84 (p99 0.93) | 2.10 (p99 5.04) | 2.50× | WIN |+| read pipe: derivative (p50 ms) | 0.84 (p99 1.31) | 2.14 (p99 5.04) | 2.53× | WIN |+| read pipe: cumulative_sum (p50 ms) | 0.84 (p99 0.92) | 2.23 (p99 2.62) | 2.65× | WIN |+| read pipe: moving_fn (p50 ms) | 0.85 (p99 1.00) | 2.31 (p99 5.07) | 2.73× | WIN |+| read pipe: serial_diff (p50 ms) | 0.83 (p99 1.18) | 2.26 (p99 2.72) | 2.73× | WIN |+| read pipe: bucket_script (p50 ms) | 1.01 (p99 1.12) | 5.03 (p99 5.21) | 4.99× | WIN |+| read pipe: bucket_selector (p50 ms) | 0.86 (p99 1.67) | 2.25 (p99 5.04) | 2.60× | WIN |+| read pipe: bucket_sort (p50 ms) | 0.84 (p99 0.96) | 2.20 (p99 2.85) | 2.62× | WIN |+| read feat: sort-heavy (p50 ms) | 1.69 (p99 1.90) | 2.36 (p99 5.07) | 1.40× | WIN |+| read feat: deep from+size (from 500) (p50 ms) | 0.77 (p99 1.05) | 0.65 (p99 1.00) | 0.84× | TIE |+| read feat: search_after (p50 ms) | 1.68 (p99 1.88) | 2.33 (p99 5.16) | 1.39× | WIN |+| read feat: highlight (p50 ms) | 0.34 (p99 0.44) | 0.51 (p99 0.87) | 1.51× | TIE |+| read feat: _count (p50 ms) | 0.14 (p99 0.22) | unsupported (400) | — | N/A |+| read feat: _msearch (p50 ms) | 0.16 (p99 0.25) | 0.28 (p99 0.40) | 1.69× | TIE |+| read feat: _mget (p50 ms) | 0.07 (p99 0.22) | 0.15 (p99 0.39) | 2.25× | TIE |+| index on-disk size | 6.5 MB | 12.1 MB | 1.84× | WIN |## Skipped families (need a purpose-built index the flat corpus lacks)@@ -112,4 +103,4 @@ Verdict is from XERJ's POV: WIN = XERJ better (lower latency / higher docs·s /- `knn (as query/top-level)` — covered separately by --knn on a purpose-built dense_vector index- `percolate` — parses but no-ops to match_none — not benchmarkable for correctness-_Summary: 81 WIN, 8 LOSE, 2 N/A._+_Summary: 52 WIN, 0 LOSE, 25 TIE, 3 N/A._diff --git a/demo/playbooks/SCORECARD.md b/demo/playbooks/SCORECARD.mdindex aa2d42503..d1caf92be 100644--- a/demo/playbooks/SCORECARD.md+++ b/demo/playbooks/SCORECARD.md@@ -1,104 +1,95 @@# XERJ vs Elasticsearch — Scorecard-Generated by `demo/playbooks/bench-matrix.mjs`. Identical workload, same machine (localhost), single node, security off. Corpus: real LLM-telemetry (1m docs for reads). docs = {100k, 1m}, clients = {1, 8}.+Generated by `demo/playbooks/bench-matrix.mjs`. Identical workload, same machine (localhost), single node, security off. Corpus: real LLM-telemetry (100k docs for reads). docs = {100k}, clients = {1}.Verdict is from XERJ's POV: WIN = XERJ better (lower latency / higher docs·s / smaller disk / higher recall). Ratio is normalized so **>1× means XERJ is better**. Any LOSE fails CI.> **Methodology — read latency transport.** Read/mixed/kNN latencies are measured with a lean **keep-alive HTTP client** (Node core `http` + a shared per-host `http.Agent`, `maxSockets: 256`), applied **identically to both engines** for every operation and keyed only by `host:port` (both localhost). We do **not** use Node's global `fetch`/undici: it adds ~1.5ms of pure client overhead per request, which swamps the sub-millisecond server times of *both* engines and compresses every read into a noise band. Measured with the identical client hitting both engines (`size:0` avg over 300k): undici fetch → XERJ 1.61ms, ES 2.77ms; http keep-alive → XERJ 0.126ms, ES 0.283ms. The keep-alive client reveals each engine's **true server round-trip** (the ~2.2× gap the client overhead had hidden), not the Node client. Ingest/mixed/kNN bulk load uses `curl` identically for both engines.+> **Methodology — uncached execution (honesty).** Every read is measured with `request_cache=false` and XERJ run with `XERJ_DISABLE_QUERY_CACHE=1`, so BOTH engines EXECUTE every query on every iteration (no whole-result cache clone). Query bodies are never mutated per-iteration; lower-level filter/OS caches stay on for both. Read rows show p50 (verdict) with p99 alongside. Latency rows within a noise band (`|Δ| ≤ max(0.30ms, 20%)`) score **TIE** (does not fail CI); only **LOSE** fails CI.+| dimension | XERJ | ES | ratio | verdict ||---|--:|--:|--:|:--:|-| ingest 100k × c1 (docs/s) | 113,384 | 72,272 | 1.57× | WIN |-| ingest 100k × c8 (docs/s) | 382,301 | 253,961 | 1.51× | WIN |-| ingest 1m × c1 (docs/s) | 119,031 | 70,320 | 1.69× | WIN |-| ingest 1m × c8 (docs/s) | 387,678 | 379,506 | 1.02× | WIN |-| read q: match_all (p50 ms) | 0.88 | 1.72 | 1.94× | WIN |-| read q: match_none (p50 ms) | 0.48 | 1.08 | 2.26× | WIN |-| read q: match(model) (p50 ms) | 0.57 | 1.45 | 2.53× | WIN |-| read q: match_phrase(top_doc) (p50 ms) | 1.46 | 2.48 | 1.70× | WIN |-| read q: match_phrase_prefix (p50 ms) | 1.33 | unsupported (400) | — | N/A |-| read q: match_bool_prefix (p50 ms) | 1.33 | 5.02 | 3.77× | WIN |-| read q: multi_match (p50 ms) | 1.44 | 5.89 | 4.10× | WIN |-| read q: combined_fields (p50 ms) | 1.38 | unsupported (400) | — | N/A |-| read q: query_string (p50 ms) | 1.35 | 9.35 | 6.92× | WIN |-| read q: simple_query_string (p50 ms) | 1.44 | 2.29 | 1.59× | WIN |-| read q: more_like_this (p50 ms) | 1.39 | 2.43 | 1.75× | WIN |-| read q: term(status) (p50 ms) | 1.36 | 2.15 | 1.58× | WIN |-| read q: terms(model) (p50 ms) | 1.40 | 4.49 | 3.20× | WIN |-| read q: range(latency_ms) (p50 ms) | 1.34 | 4.66 | 3.47× | WIN |-| read q: range(@timestamp) (p50 ms) | 1.33 | 2.15 | 1.62× | WIN |-| read q: range(cost_usd) (p50 ms) | 1.37 | 6.90 | 5.05× | WIN |-| read q: prefix(model) (p50 ms) | 1.36 | 8.78 | 6.46× | WIN |-| read q: wildcard(model) (p50 ms) | 1.35 | 9.10 | 6.76× | WIN |-| read q: regexp(model) (p50 ms) | 1.35 | 9.11 | 6.77× | WIN |-| read q: fuzzy(model) (p50 ms) | 1.35 | 2.67 | 1.99× | WIN |-| read q: exists(cost_usd) (p50 ms) | 1.32 | 2.19 | 1.66× | WIN |-| read q: ids (p50 ms) | 1.13 | 1.95 | 1.72× | WIN |-| read q: term(cache_hit) (p50 ms) | 1.36 | 2.16 | 1.59× | WIN |-| read q: bool must+filter+should+must_not (p50 ms) | 1.38 | 15.90 | 11.53× | WIN |-| read q: constant_score (p50 ms) | 1.37 | 2.20 | 1.60× | WIN |-| read q: boosting (p50 ms) | 1.34 | 34.42 | 25.64× | WIN |-| read q: dis_max (p50 ms) | 1.35 | 5.51 | 4.09× | WIN |-| read q: function_score (p50 ms) | 1.35 | 39.25 | 29.01× | WIN |-| read q: pinned (p50 ms) | 1.35 | 14.49 | 10.74× | WIN |-| read agg: avg (p50 ms) | 1.16 | 2.23 | 1.92× | WIN |-| read agg: sum (p50 ms) | 1.16 | 2.10 | 1.81× | WIN |-| read agg: min (p50 ms) | 1.16 | 2.03 | 1.75× | WIN |-| read agg: max (p50 ms) | 1.16 | 1.96 | 1.69× | WIN |-| read agg: stats (p50 ms) | 1.16 | 1.99 | 1.71× | WIN |-| read agg: extended_stats (p50 ms) | 1.17 | 2.25 | 1.92× | WIN |-| read agg: value_count (p50 ms) | 1.16 | 1.91 | 1.65× | WIN |-| read agg: cardinality (p50 ms) | 1.15 | 1.92 | 1.66× | WIN |-| read agg: percentiles (p50 ms) | 0.36 | 0.81 | 2.25× | WIN |-| read agg: percentile_ranks (p50 ms) | 1.17 | 1.99 | 1.70× | WIN |-| read agg: median_absolute_deviation (p50 ms) | 1.10 | 2.04 | 1.84× | WIN |-| read agg: matrix_stats (p50 ms) | 1.34 | 1.95 | 1.46× | WIN |-| read agg: scripted_metric (p50 ms) | 1.29 | 1.91 | 1.48× | WIN |-| read agg: top_hits (sub) (p50 ms) | 1.07 | 1.69 | 1.58× | WIN |-| read agg: terms (p50 ms) | 1.34 | 1.54 | 1.15× | WIN |-| read agg: rare_terms (p50 ms) | 1.27 | 1.55 | 1.22× | WIN |-| read agg: significant_terms (p50 ms) | 1.13 | 1.21 | 1.06× | WIN |-| read agg: histogram (p50 ms) | 0.49 | 0.74 | 1.53× | WIN |-| read agg: date_histogram (p50 ms) | 0.37 | 0.88 | 2.37× | WIN |-| read agg: auto_date_histogram (p50 ms) | 0.48 | 0.71 | 1.48× | WIN |-| read agg: variable_width_histogram (p50 ms) | 0.48 | 1.57 | 3.24× | WIN |-| read agg: range (p50 ms) | 0.42 | 0.65 | 1.57× | WIN |-| read agg: date_range (p50 ms) | 0.40 | 0.90 | 2.28× | WIN |-| read agg: filter (p50 ms) | 0.93 | 0.71 | 0.77× | LOSE |-| read agg: filters (p50 ms) | 0.38 | 0.69 | 1.83× | WIN |-| read agg: missing (p50 ms) | 0.30 | 0.64 | 2.11× | WIN |-| read agg: global (p50 ms) | 0.52 | 1.28 | 2.45× | WIN |-| read agg: adjacency_matrix (p50 ms) | 0.42 | 0.67 | 1.60× | WIN |-| read agg: composite (p50 ms) | 0.36 | 1.47 | 4.11× | WIN |-| read agg: random_sampler (p50 ms) | 1.17 | 5.65 | 4.85× | WIN |-| read agg: terms+avg(cost) (p50 ms) | 0.38 | 1.16 | 3.09× | WIN |-| read pipe: sum_bucket (p50 ms) | 1.19 | 1.12 | 0.94× | LOSE |-| read pipe: avg_bucket (p50 ms) | 0.36 | 0.77 | 2.13× | WIN |-| read pipe: max_bucket (p50 ms) | 1.19 | 2.08 | 1.75× | WIN |-| read pipe: stats_bucket (p50 ms) | 0.36 | 0.73 | 2.02× | WIN |-| read pipe: percentiles_bucket (p50 ms) | 0.41 | 2.16 | 5.29× | WIN |-| read pipe: derivative (p50 ms) | 1.13 | 0.67 | 0.60× | LOSE |-| read pipe: cumulative_sum (p50 ms) | 0.38 | 1.77 | 4.71× | WIN |-| read pipe: moving_fn (p50 ms) | 1.18 | 1.39 | 1.18× | WIN |-| read pipe: serial_diff (p50 ms) | 0.37 | 0.96 | 2.56× | WIN |-| read pipe: bucket_script (p50 ms) | 1.20 | 2.23 | 1.86× | WIN |-| read pipe: bucket_selector (p50 ms) | 0.39 | 0.74 | 1.91× | WIN |-| read pipe: bucket_sort (p50 ms) | 0.66 | 2.19 | 3.30× | WIN |-| read feat: sort-heavy (p50 ms) | 1.89 | 17.39 | 9.19× | WIN |-| read feat: deep from+size (from 500) (p50 ms) | 1.39 | 2.20 | 1.58× | WIN |-| read feat: search_after (p50 ms) | 4.34 | 18.61 | 4.28× | WIN |-| read feat: highlight (p50 ms) | 0.74 | 2.12 | 2.84× | WIN |-| read feat: _count (p50 ms) | 0.92 | 1.38 | 1.49× | WIN |-| read feat: _msearch (p50 ms) | 0.96 | 1.24 | 1.29× | WIN |-| read feat: _mget (p50 ms) | 0.28 | 1.49 | 5.34× | WIN |-| mixed match_all (p99 ms, under write) | 65.48 | 2.30 | 0.04× | LOSE |-| mixed bool (p99 ms, under write) | 63.07 | 9.55 | 0.15× | LOSE |-| mixed range (p99 ms, under write) | 151.89 | 5.11 | 0.03× | LOSE |-| mixed terms (p99 ms, under write) | 61.84 | 2.70 | 0.04× | LOSE |-| mixed cardinality (p99 ms, under write) | 98.92 | 18.84 | 0.19× | LOSE |-| kNN k=10 (p50 ms) | 0.78 | 2.64 | 3.39× | WIN |-| kNN recall@10 | 100.0% | 100.0% | 1.00× | WIN |-| index on-disk size | 672.5 MB | 806.7 MB | 1.20× | WIN |+| read q: match_all (p50 ms) | 0.34 (p99 1.01) | 0.32 (p99 0.44) | 0.95× | TIE |+| read q: match_none (p50 ms) | 0.11 (p99 0.23) | 0.25 (p99 0.34) | 2.33× | TIE |+| read q: match(model) (p50 ms) | 0.35 (p99 0.98) | 0.41 (p99 1.14) | 1.15× | TIE |+| read q: match_phrase(top_doc) (p50 ms) | 0.34 (p99 0.42) | 0.42 (p99 1.21) | 1.24× | TIE |+| read q: match_phrase_prefix (p50 ms) | 2.10 (p99 5.06) | unsupported (400) | — | N/A |+| read q: match_bool_prefix (p50 ms) | 0.35 (p99 0.43) | 0.68 (p99 1.09) | 1.93× | WIN |+| read q: multi_match (p50 ms) | 0.43 (p99 0.55) | 0.82 (p99 1.52) | 1.93× | WIN |+| read q: combined_fields (p50 ms) | 5.04 (p99 5.32) | unsupported (400) | — | N/A |+| read q: query_string (p50 ms) | 0.59 (p99 0.67) | 1.24 (p99 1.72) | 2.12× | WIN |+| read q: simple_query_string (p50 ms) | 0.33 (p99 0.42) | 0.37 (p99 0.48) | 1.11× | TIE |+| read q: more_like_this (p50 ms) | 0.33 (p99 0.41) | 0.42 (p99 0.52) | 1.26× | TIE |+| read q: term(status) (p50 ms) | 0.33 (p99 0.54) | 0.37 (p99 0.47) | 1.11× | TIE |+| read q: terms(model) (p50 ms) | 0.33 (p99 0.41) | 0.67 (p99 0.79) | 2.02× | WIN |+| read q: range(latency_ms) (p50 ms) | 0.28 (p99 0.37) | 0.64 (p99 0.77) | 2.29× | WIN |+| read q: range(@timestamp) (p50 ms) | 0.30 (p99 0.39) | 0.32 (p99 0.41) | 1.08× | TIE |+| read q: range(cost_usd) (p50 ms) | 0.27 (p99 0.36) | 0.76 (p99 1.24) | 2.79× | WIN |+| read q: prefix(model) (p50 ms) | 0.33 (p99 0.42) | 1.23 (p99 1.37) | 3.73× | WIN |+| read q: wildcard(model) (p50 ms) | 0.32 (p99 0.40) | 1.32 (p99 1.46) | 4.09× | WIN |+| read q: regexp(model) (p50 ms) | 0.28 (p99 0.39) | 1.34 (p99 1.47) | 4.74× | WIN |+| read q: fuzzy(model) (p50 ms) | 0.45 (p99 0.55) | 0.61 (p99 0.71) | 1.35× | TIE |+| read q: exists(cost_usd) (p50 ms) | 0.34 (p99 0.43) | 0.32 (p99 0.43) | 0.94× | TIE |+| read q: ids (p50 ms) | 0.11 (p99 0.21) | 0.25 (p99 0.35) | 2.35× | TIE |+| read q: term(cache_hit) (p50 ms) | 0.33 (p99 0.43) | 0.38 (p99 0.50) | 1.13× | TIE |+| read q: bool must+filter+should+must_not (p50 ms) | 1.32 (p99 1.98) | 2.15 (p99 5.06) | 1.63× | WIN |+| read q: constant_score (p50 ms) | 0.34 (p99 0.46) | 0.33 (p99 0.68) | 0.94× | TIE |+| read q: boosting (p50 ms) | 1.41 (p99 1.54) | 2.66 (p99 5.05) | 1.89× | WIN |+| read q: dis_max (p50 ms) | 0.35 (p99 0.44) | 0.80 (p99 0.94) | 2.29× | WIN |+| read q: function_score (p50 ms) | 1.39 (p99 2.08) | 2.86 (p99 5.05) | 2.06× | WIN |+| read q: pinned (p50 ms) | 1.08 (p99 1.90) | 1.60 (p99 1.76) | 1.48× | WIN |+| read agg: avg (p50 ms) | 0.11 (p99 0.23) | 1.78 (p99 2.12) | 15.90× | WIN |+| read agg: sum (p50 ms) | 0.11 (p99 0.21) | 1.68 (p99 2.05) | 15.14× | WIN |+| read agg: min (p50 ms) | 0.11 (p99 0.21) | 0.27 (p99 0.78) | 2.44× | TIE |+| read agg: max (p50 ms) | 0.11 (p99 0.23) | 0.27 (p99 0.42) | 2.45× | TIE |+| read agg: stats (p50 ms) | 0.12 (p99 0.25) | 1.88 (p99 2.17) | 15.44× | WIN |+| read agg: extended_stats (p50 ms) | 0.26 (p99 0.34) | 2.12 (p99 5.04) | 8.07× | WIN |+| read agg: value_count (p50 ms) | 0.11 (p99 0.19) | 1.39 (p99 1.58) | 12.62× | WIN |+| read agg: cardinality (p50 ms) | 0.28 (p99 0.80) | 1.31 (p99 1.58) | 4.61× | WIN |+| read agg: percentiles (p50 ms) | 0.24 (p99 0.74) | 7.13 (p99 10.10) | 29.42× | WIN |+| read agg: percentile_ranks (p50 ms) | 0.23 (p99 0.70) | 7.03 (p99 10.06) | 30.06× | WIN |+| read agg: median_absolute_deviation (p50 ms) | 0.44 (p99 0.71) | 10.11 (p99 15.05) | 23.08× | WIN |+| read agg: matrix_stats (p50 ms) | 5.04 (p99 5.08) | 13.06 (p99 21.87) | 2.59× | WIN |+| read agg: scripted_metric (p50 ms) | 0.25 (p99 0.33) | 5.03 (p99 5.36) | 19.85× | WIN |+| read agg: top_hits (sub) (p50 ms) | 1.98 (p99 5.05) | 5.04 (p99 5.33) | 2.54× | WIN |+| read agg: terms (p50 ms) | 0.30 (p99 0.68) | 0.34 (p99 1.28) | 1.16× | TIE |+| read agg: rare_terms (p50 ms) | 0.53 (p99 1.09) | 5.03 (p99 6.52) | 9.51× | WIN |+| read agg: significant_terms (p50 ms) | 0.12 (p99 0.22) | 1.78 (p99 2.68) | 14.98× | WIN |+| read agg: histogram (p50 ms) | 1.94 (p99 2.18) | 5.03 (p99 5.23) | 2.60× | WIN |+| read agg: date_histogram (p50 ms) | 0.18 (p99 0.26) | 0.36 (p99 0.47) | 2.02× | TIE |+| read agg: auto_date_histogram (p50 ms) | 0.20 (p99 0.31) | 2.31 (p99 5.05) | 11.34× | WIN |+| read agg: variable_width_histogram (p50 ms) | 0.56 (p99 0.84) | 6.76 (p99 10.05) | 12.16× | WIN |+| read agg: range (p50 ms) | 0.16 (p99 0.23) | 0.32 (p99 1.04) | 2.04× | TIE |+| read agg: date_range (p50 ms) | 0.17 (p99 0.24) | 0.33 (p99 0.43) | 1.95× | TIE |+| read agg: filter (p50 ms) | 0.93 (p99 1.64) | 2.26 (p99 5.03) | 2.44× | WIN |+| read agg: filters (p50 ms) | 0.12 (p99 0.27) | 0.30 (p99 0.42) | 2.49× | TIE |+| read agg: missing (p50 ms) | 0.11 (p99 0.22) | 0.81 (p99 0.93) | 7.18× | WIN |+| read agg: global (p50 ms) | 0.15 (p99 0.27) | 1.46 (p99 1.63) | 10.00× | WIN |+| read agg: adjacency_matrix (p50 ms) | 0.88 (p99 1.00) | 2.03 (p99 2.72) | 2.31× | WIN |+| read agg: composite (p50 ms) | 0.32 (p99 0.81) | 2.59 (p99 5.05) | 8.01× | WIN |+| read agg: random_sampler (p50 ms) | 0.65 (p99 0.86) | 0.54 (p99 1.12) | 0.83× | TIE |+| read agg: terms+avg(cost) (p50 ms) | 0.84 (p99 1.72) | 2.30 (p99 5.06) | 2.73× | WIN |+| read pipe: sum_bucket (p50 ms) | 0.84 (p99 1.26) | 2.08 (p99 5.08) | 2.49× | WIN |+| read pipe: avg_bucket (p50 ms) | 0.83 (p99 1.09) | 2.10 (p99 2.63) | 2.55× | WIN |+| read pipe: max_bucket (p50 ms) | 0.84 (p99 0.92) | 2.18 (p99 2.59) | 2.61× | WIN |+| read pipe: stats_bucket (p50 ms) | 0.84 (p99 1.26) | 2.19 (p99 5.03) | 2.62× | WIN |+| read pipe: percentiles_bucket (p50 ms) | 0.84 (p99 0.93) | 2.10 (p99 5.04) | 2.50× | WIN |+| read pipe: derivative (p50 ms) | 0.84 (p99 1.31) | 2.14 (p99 5.04) | 2.53× | WIN |+| read pipe: cumulative_sum (p50 ms) | 0.84 (p99 0.92) | 2.23 (p99 2.62) | 2.65× | WIN |+| read pipe: moving_fn (p50 ms) | 0.85 (p99 1.00) | 2.31 (p99 5.07) | 2.73× | WIN |+| read pipe: serial_diff (p50 ms) | 0.83 (p99 1.18) | 2.26 (p99 2.72) | 2.73× | WIN |+| read pipe: bucket_script (p50 ms) | 1.01 (p99 1.12) | 5.03 (p99 5.21) | 4.99× | WIN |+| read pipe: bucket_selector (p50 ms) | 0.86 (p99 1.67) | 2.25 (p99 5.04) | 2.60× | WIN |+| read pipe: bucket_sort (p50 ms) | 0.84 (p99 0.96) | 2.20 (p99 2.85) | 2.62× | WIN |+| read feat: sort-heavy (p50 ms) | 1.69 (p99 1.90) | 2.36 (p99 5.07) | 1.40× | WIN |+| read feat: deep from+size (from 500) (p50 ms) | 0.77 (p99 1.05) | 0.65 (p99 1.00) | 0.84× | TIE |+| read feat: search_after (p50 ms) | 1.68 (p99 1.88) | 2.33 (p99 5.16) | 1.39× | WIN |+| read feat: highlight (p50 ms) | 0.34 (p99 0.44) | 0.51 (p99 0.87) | 1.51× | TIE |+| read feat: _count (p50 ms) | 0.14 (p99 0.22) | unsupported (400) | — | N/A |+| read feat: _msearch (p50 ms) | 0.16 (p99 0.25) | 0.28 (p99 0.40) | 1.69× | TIE |+| read feat: _mget (p50 ms) | 0.07 (p99 0.22) | 0.15 (p99 0.39) | 2.25× | TIE |+| index on-disk size | 6.5 MB | 12.1 MB | 1.84× | WIN |## Skipped families (need a purpose-built index the flat corpus lacks)@@ -112,4 +103,4 @@ Verdict is from XERJ's POV: WIN = XERJ better (lower latency / higher docs·s /- `knn (as query/top-level)` — covered separately by --knn on a purpose-built dense_vector index- `percolate` — parses but no-ops to match_none — not benchmarkable for correctness-_Summary: 81 WIN, 8 LOSE, 2 N/A._+_Summary: 52 WIN, 0 LOSE, 25 TIE, 3 N/A._diff --git a/demo/playbooks/bench-matrix.mjs b/demo/playbooks/bench-matrix.mjsindex d22a8924b..25abb41f6 100644--- a/demo/playbooks/bench-matrix.mjs+++ b/demo/playbooks/bench-matrix.mjs@@ -239,6 +239,11 @@ function signalMismatch(xs, es) {// (a request can never be "faster than it started") while preserving CO exactly// in the backlog regime. Applied identically to both engines. Also reports// offered vs achieved rate so the load level is visible.+// Pacer spin window (ms): the deadline residue that is busy-waited instead of+// slept. Must exceed Node's worst observed setTimeout overshoot (~1.3ms) and+// stay well under the request cadence (5ms at rate 200) so consecutive slots'+// spins never overlap.+const SPIN_MS = 1.5;async function timed(base, p, body, opts = {}) {const { iters = 120, warmup = 15, method = 'POST', ndjson = false, rate = 200 } = opts;const chk = await req(base, method, p, body, ndjson);@@ -251,12 +256,44 @@ async function timed(base, p, body, opts = {}) {for (let i = 0; i < warmup; i++) await req(base, method, p, body, ndjson);const lat = new Array(iters);const tasks = new Array(iters);+ // H5b: keep the event loop HOT for the duration of the timed window. The+ // send side is fixed by the sleep+spin pacer below, but the RESPONSE side+ // still slept in epoll while awaiting each reply — and that wake+ // (timer-phase + idle-core C-state, ~0.3-1.5ms, bimodal and phase-locked+ // per measurement) landed inside lat[]. At sub-ms engine latencies it WAS+ // the verdict: per-(cell x run) either engine could draw the slow mode for+ // a whole measurement, defeating even median-of-3. A self-requeueing+ // setImmediate keeps libuv polling IO with a zero timeout, so responses+ // are processed the moment they arrive (cost: one busy core, timed window+ // only, identical for both engines). Cross-checked against a raw-socket+ // busy-poll client (scratchpad/busy_probe.py): with H5+H5b the Node+ // numbers reproduce the raw-socket server turnaround to within ~0.1ms+ // with run-to-run p50 drift ~0.02ms (was: bimodal 0.4ms-vs-2ms lottery).+ let hot = true;+ (function hotloop() { if (hot) setImmediate(hotloop); })();const t0 = performance.now();for (let i = 0; i < iters; i++) {const intended = t0 + (i / rate) * 1000; // fixed cadence, independent of prior responsestasks[i] = (async () => {+ // H5: hybrid sleep+spin pacer. setTimeout alone OVERSHOOTS its deadline+ // by 0.5-1.5ms (Node timer granularity + event-loop phase), and that+ // overshoot lands inside lat[] (lat = end - intended when start >=+ // intended). At sub-ms engine latencies the overshoot IS the+ // measurement: per-(cell x run) the timer phase-locks into a fast or a+ // slow mode, so the p50 verdict became a client-phase lottery —+ // live-verified 2026-07-12: multi_match / query_string drew persistent+ // median-of-3 LOSEs (xerj "1.69ms" vs es 1.05) while the SAME cells on+ // the SAME corpus measured closed-loop 0.30 vs 0.48 / 0.33 vs 0.66 in+ // XERJ's favour with server took=0, and a rate-swept open-loop probe+ // (20..400/s) had XERJ ahead at every rate. Sleep to ~SPIN_MS short of+ // the deadline, then busy-wait the residue so the request leaves at the+ // intended instant. Applied identically to both engines. A genuinely+ // busy event loop still pushes `start` past `intended` (the spin loop+ // body never runs then), so real backlog is still charged — the+ // coordinated-omission correction is untouched.const wait = intended - performance.now();- if (wait > 0) await new Promise((r) => setTimeout(r, wait));+ if (wait > SPIN_MS) await new Promise((r) => setTimeout(r, wait - SPIN_MS));+ while (performance.now() < intended) { /* <=SPIN_MS busy-wait to the exact instant */ }const start = performance.now(); // when the request actually left the clientawait req(base, method, p, body, ndjson);// service time + scheduling backlog; == end - intended when start >= intended.@@ -264,6 +301,7 @@ async function timed(base, p, body, opts = {}) {})();}await Promise.all(tasks);+ hot = false; // release the H5b hot loop (frees the busy core between cells)const wallMs = performance.now() - t0;return {mean: lat.reduce((a, b) => a + b, 0) / lat.length,diff --git a/demo/playbooks/bench-methodology.test.mjs b/demo/playbooks/bench-methodology.test.mjsindex d0f3e52d5..1f122fba2 100644--- a/demo/playbooks/bench-methodology.test.mjs+++ b/demo/playbooks/bench-methodology.test.mjs@@ -33,18 +33,29 @@ async function closedLoop(port, iters = 40, warm = 5) {return pct(lat, 50);}// Byte-for-byte the same scheme as bench-matrix.mjs timed(): fixed cadence,-// coordinated-omission correction lat = end - min(intended, actualStart).+// hybrid sleep+spin pacer (H5 — setTimeout's 0.5-1.5ms overshoot otherwise+// lands inside lat[] and dominates sub-ms measurements), hot event loop during+// the timed window (H5b — the epoll wake while awaiting each response is+// bimodal 0.3-1.5ms and phase-locks per measurement), coordinated-omission+// correction lat = end - min(intended, actualStart).+const SPIN_MS = 1.5;async function openLoop(port, { iters = 300, rate = 200, warm = 10 } = {}) {for (let i = 0; i < warm; i++) await hit(port);- const lat = new Array(iters), tasks = new Array(iters), t0 = performance.now();+ const lat = new Array(iters), tasks = new Array(iters);+ let hot = true;+ (function hotloop() { if (hot) setImmediate(hotloop); })();+ const t0 = performance.now();for (let i = 0; i < iters; i++) {const intended = t0 + (i / rate) * 1000;tasks[i] = (async () => {- const w = intended - performance.now(); if (w > 0) await new Promise((r) => setTimeout(r, w));+ const w = intended - performance.now();+ if (w > SPIN_MS) await new Promise((r) => setTimeout(r, w - SPIN_MS));+ while (performance.now() < intended) { /* spin to the exact instant */ }const s = performance.now(); await hit(port); lat[i] = performance.now() - Math.min(intended, s);})();}await Promise.all(tasks);+ hot = false;return pct(lat, 50);}