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
perf(#1024): lazy request-cache seen-set — 206 to 64 kB/idx idle RSS (#1025)
xerj-orgeec3459ac891
diff --git a/benchmarks/idle-budget/README.md b/benchmarks/idle-budget/README.mdindex ecd154bb3..42589ea08 100644--- a/benchmarks/idle-budget/README.md+++ b/benchmarks/idle-budget/README.md@@ -178,6 +178,52 @@ Overrides (`GATE_CPU_PERCENT`, `GATE_WAKEUPS_PER_S`,defaults are the CI contract. If a gate fails, the finding is the point — donot move the line to make a run pass.+### Calibration update, 2026-09-22 — #1024 tranche 1 (lazy request-cache seen-set)++`6526e8ea` (`perf(#1024): request-cache seen-set allocates on first tracked+search`) removed the eager `RequestCacheSeen::with_capacity(65_536)` at both+`Index` construction sites: the seen-set now starts empty and grows on first+`record()`, so an index that has never served a `request_cache=true` search+holds nothing. Same host, same fixture, `ci-test` binaries, allocator pins+on; before-binary rebuilt from `ed510a61` (the commit's parent, single-file+diff). Result files: `result-p1024-n150-4cpu.json`,+`result-p1024-n450-4cpu.json` (before, 4-vCPU), `result-p1024-after-n150-4cpu.json`,+`result-p1024-after-n450-4cpu.json` (after, 4-vCPU), `result-p1024-before-32cpu-n450.json`+/ `result-p1024-after-32cpu.json` / `result-p1024-after-32cpu-rerun.json`+(32-vCPU N=450 pair — the before arm was added because every earlier 32-vCPU+reading was N=300).++| 4-vCPU (`taskset -c 0-3`) | before | after | Δ |+|---|---|---|---|+| per-index idle RSS, N=150 | 204.9 kB | 63.2 kB | −69 % |+| per-index idle RSS, N=450 | 203.7 kB | 63.3 kB | −69 % |+| N-slope, VmRSS (450−150)/300 | 206.5 kB/idx | 63.7 kB/idx | −69 % |+| N-slope, RssAnon (450−150)/300 | 205.7 kB/idx | 68.8 kB/idx | −67 % |+| idle CPU, N=450 | 0.225 % | 0.192 % | −15 %rel |+| wakeups/s, N=450 | 25.2 | 21.4 | − |+| boot-to-green, N=450 | 6 ms | 6 ms | — |+| WAL replay after clean flush | 0 | 0 | — |++| 32 vCPU (unpinned), N=450 | before | after (2 runs) |+|---|---|---|+| per-index idle RSS | 199.0 kB | 66.3 / 62.6 kB |+| idle CPU | 0.767 % (loadavg 19) | 0.650 / 0.633 % (loadavg 3–4) |+| wakeups/s | 22.6 | 25.9 / 22.2 |+| boot-to-green | 385 ms (loaded window) | 113 / 7 ms |++The subtraction and the N-slope now agree (~64 kB/idx): the curve is flat at+a genuinely O(N)-constant ~0.06 MB/index, and issue #874's 0.2 MB/index+product line is met on both host shapes with >3× margin. The remaining+~64 kB/idx is the next tranche's target (per-index DashMap shard arrays,+WAL/memtable shard structs, parsed settings/mapping copies).++Pre-existing, unchanged by this commit: the unpinned 32-vCPU arm at N=450+reads >0.5 % idle CPU on the **before** binary too (0.767 %) — the gate line+was calibrated on 4-vCPU and quiet-N=300 windows, and both binaries trip it+on that arm on this shared box. The controlled 4-vCPU pair above is the+comparison that matters; wakeups (the timer-churn proxy) are flat on every+arm. The issue stays open for the follow-up tranches.+## Reproduce```shdiff --git a/benchmarks/idle-budget/results/result-p1024-after-32cpu-rerun.json b/benchmarks/idle-budget/results/result-p1024-after-32cpu-rerun.jsonnew file mode 100644index 000000000..7247e4721--- /dev/null+++ b/benchmarks/idle-budget/results/result-p1024-after-32cpu-rerun.json@@ -0,0 +1,108 @@+{+ "label": "p1024-after-32cpu-rerun",+ "date_utc": "2026-09-22T04:21:14+00:00",+ "binary": {+ "version": "xerj v1.0.0-rc.77",+ "path": "/root/xerj-1024/engine/target/ci-test/xerj"+ },+ "corpus": {+ "shape": "15x30",+ "indices": 450,+ "docs_per_index": 3+ },+ "port": 9610,+ "window_s": 120.0,+ "settle_target_s": 120.0,+ "boot_ms": {+ "empty_node": 7,+ "baseline_arm": 6,+ "n_indices": 7+ },+ "wal_replay_lines_after_clean_flush": 0,+ "doc_probe_hits": 3,+ "baseline": {+ "pid": 3779830,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 11,+ "cpu_percent_of_one_core": 0.0917,+ "wakeups_per_s": 23.7,+ "voluntary_per_s": 23.7,+ "nonvoluntary_per_s": 0.1,+ "rss_kb": 77892,+ "hwm_kb": 78860,+ "rss_anon_kb": 47404,+ "rss_file_kb": 30488,+ "anon_hugepages_kb": 0,+ "threads": 340,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 4,+ "threads": 1,+ "cpu_percent_of_one_core": 0.033+ },+ {+ "comm": "xerj-rt",+ "cpu_ticks": 3,+ "threads": 1,+ "cpu_percent_of_one_core": 0.025+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 1,+ "threads": 1,+ "cpu_percent_of_one_core": 0.008+ }+ ],+ "loadavg_start": [+ "2.45",+ "10.52",+ "12.76"+ ]+ },+ "measurement": {+ "pid": 3781903,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 76,+ "cpu_percent_of_one_core": 0.6333,+ "wakeups_per_s": 22.2,+ "voluntary_per_s": 21.9,+ "nonvoluntary_per_s": 0.4,+ "rss_kb": 106084,+ "hwm_kb": 106084,+ "rss_anon_kb": 73636,+ "rss_file_kb": 32448,+ "anon_hugepages_kb": 0,+ "threads": 336,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-rt",+ "cpu_ticks": 64,+ "threads": 3,+ "cpu_percent_of_one_core": 0.533+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 8,+ "threads": 1,+ "cpu_percent_of_one_core": 0.067+ },+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 4,+ "threads": 1,+ "cpu_percent_of_one_core": 0.033+ }+ ],+ "loadavg_start": [+ "3.24",+ "7.58",+ "11.29"+ ]+ },+ "per_index_rss_kb": 62.6+}\ No newline at end of filediff --git a/benchmarks/idle-budget/results/result-p1024-after-32cpu.json b/benchmarks/idle-budget/results/result-p1024-after-32cpu.jsonnew file mode 100644index 000000000..efcc5e04a--- /dev/null+++ b/benchmarks/idle-budget/results/result-p1024-after-32cpu.json@@ -0,0 +1,108 @@+{+ "label": "p1024-after-32cpu",+ "date_utc": "2026-09-22T04:06:02+00:00",+ "binary": {+ "version": "xerj v1.0.0-rc.77",+ "path": "/root/xerj-1024/engine/target/ci-test/xerj"+ },+ "corpus": {+ "shape": "15x30",+ "indices": 450,+ "docs_per_index": 3+ },+ "port": 9610,+ "window_s": 120.0,+ "settle_target_s": 120.0,+ "boot_ms": {+ "empty_node": 5,+ "baseline_arm": 7,+ "n_indices": 113+ },+ "wal_replay_lines_after_clean_flush": 0,+ "doc_probe_hits": 3,+ "baseline": {+ "pid": 3772779,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 11,+ "cpu_percent_of_one_core": 0.0917,+ "wakeups_per_s": 23.7,+ "voluntary_per_s": 23.5,+ "nonvoluntary_per_s": 0.2,+ "rss_kb": 76540,+ "hwm_kb": 76644,+ "rss_anon_kb": 47304,+ "rss_file_kb": 29236,+ "anon_hugepages_kb": 0,+ "threads": 340,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 4,+ "threads": 1,+ "cpu_percent_of_one_core": 0.033+ },+ {+ "comm": "xerj-rt",+ "cpu_ticks": 3,+ "threads": 1,+ "cpu_percent_of_one_core": 0.025+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 2,+ "threads": 1,+ "cpu_percent_of_one_core": 0.017+ }+ ],+ "loadavg_start": [+ "3.34",+ "3.76",+ "7.98"+ ]+ },+ "measurement": {+ "pid": 3774882,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 78,+ "cpu_percent_of_one_core": 0.6499,+ "wakeups_per_s": 25.9,+ "voluntary_per_s": 25.5,+ "nonvoluntary_per_s": 0.4,+ "rss_kb": 106360,+ "hwm_kb": 106360,+ "rss_anon_kb": 74008,+ "rss_file_kb": 32352,+ "anon_hugepages_kb": 0,+ "threads": 336,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-rt",+ "cpu_ticks": 62,+ "threads": 3,+ "cpu_percent_of_one_core": 0.517+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 10,+ "threads": 1,+ "cpu_percent_of_one_core": 0.083+ },+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 3,+ "threads": 1,+ "cpu_percent_of_one_core": 0.025+ }+ ],+ "loadavg_start": [+ "3.57",+ "3.86",+ "7.35"+ ]+ },+ "per_index_rss_kb": 66.3+}\ No newline at end of filediff --git a/benchmarks/idle-budget/results/result-p1024-after-n150-4cpu.json b/benchmarks/idle-budget/results/result-p1024-after-n150-4cpu.jsonnew file mode 100644index 000000000..c189a8de6--- /dev/null+++ b/benchmarks/idle-budget/results/result-p1024-after-n150-4cpu.json@@ -0,0 +1,108 @@+{+ "label": "p1024-after-n150-4cpu",+ "date_utc": "2026-09-22T03:59:12+00:00",+ "binary": {+ "version": "xerj v1.0.0-rc.77",+ "path": "/root/xerj-1024/engine/target/ci-test/xerj"+ },+ "corpus": {+ "shape": "5x30",+ "indices": 150,+ "docs_per_index": 3+ },+ "port": 9610,+ "window_s": 120.0,+ "settle_target_s": 120.0,+ "boot_ms": {+ "empty_node": 5,+ "baseline_arm": 5,+ "n_indices": 5+ },+ "wal_replay_lines_after_clean_flush": 0,+ "doc_probe_hits": 3,+ "baseline": {+ "pid": 3771285,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 7,+ "cpu_percent_of_one_core": 0.0583,+ "wakeups_per_s": 24.7,+ "voluntary_per_s": 24.6,+ "nonvoluntary_per_s": 0.1,+ "rss_kb": 47140,+ "hwm_kb": 47144,+ "rss_anon_kb": 16696,+ "rss_file_kb": 30444,+ "anon_hugepages_kb": 0,+ "threads": 82,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 3,+ "threads": 1,+ "cpu_percent_of_one_core": 0.025+ },+ {+ "comm": "xerj-rt",+ "cpu_ticks": 1,+ "threads": 1,+ "cpu_percent_of_one_core": 0.008+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 1,+ "threads": 1,+ "cpu_percent_of_one_core": 0.008+ }+ ],+ "loadavg_start": [+ "4.04",+ "5.27",+ "10.45"+ ]+ },+ "measurement": {+ "pid": 3771786,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 17,+ "cpu_percent_of_one_core": 0.1417,+ "wakeups_per_s": 24.7,+ "voluntary_per_s": 24.6,+ "nonvoluntary_per_s": 0.1,+ "rss_kb": 56620,+ "hwm_kb": 56620,+ "rss_anon_kb": 24196,+ "rss_file_kb": 32424,+ "anon_hugepages_kb": 0,+ "threads": 82,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 5,+ "threads": 1,+ "cpu_percent_of_one_core": 0.042+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 4,+ "threads": 1,+ "cpu_percent_of_one_core": 0.033+ },+ {+ "comm": "xerj-rt",+ "cpu_ticks": 3,+ "threads": 2,+ "cpu_percent_of_one_core": 0.025+ }+ ],+ "loadavg_start": [+ "3.59",+ "4.70",+ "9.48"+ ]+ },+ "per_index_rss_kb": 63.2+}\ No newline at end of filediff --git a/benchmarks/idle-budget/results/result-p1024-after-n450-4cpu.json b/benchmarks/idle-budget/results/result-p1024-after-n450-4cpu.jsonnew file mode 100644index 000000000..1c63a69b4--- /dev/null+++ b/benchmarks/idle-budget/results/result-p1024-after-n450-4cpu.json@@ -0,0 +1,108 @@+{+ "label": "p1024-after-n450-4cpu",+ "date_utc": "2026-09-22T03:52:12+00:00",+ "binary": {+ "version": "xerj v1.0.0-rc.77",+ "path": "/root/xerj-1024/engine/target/ci-test/xerj"+ },+ "corpus": {+ "shape": "15x30",+ "indices": 450,+ "docs_per_index": 3+ },+ "port": 9610,+ "window_s": 120.0,+ "settle_target_s": 120.0,+ "boot_ms": {+ "empty_node": 7,+ "baseline_arm": 5,+ "n_indices": 6+ },+ "wal_replay_lines_after_clean_flush": 0,+ "doc_probe_hits": 3,+ "baseline": {+ "pid": 3769704,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 6,+ "cpu_percent_of_one_core": 0.05,+ "wakeups_per_s": 24.7,+ "voluntary_per_s": 24.6,+ "nonvoluntary_per_s": 0.0,+ "rss_kb": 47240,+ "hwm_kb": 47380,+ "rss_anon_kb": 16596,+ "rss_file_kb": 30644,+ "anon_hugepages_kb": 0,+ "threads": 82,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 2,+ "threads": 1,+ "cpu_percent_of_one_core": 0.017+ },+ {+ "comm": "xerj-rt",+ "cpu_ticks": 1,+ "threads": 1,+ "cpu_percent_of_one_core": 0.008+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 1,+ "threads": 1,+ "cpu_percent_of_one_core": 0.008+ }+ ],+ "loadavg_start": [+ "4.15",+ "12.55",+ "14.82"+ ]+ },+ "measurement": {+ "pid": 3770820,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 23,+ "cpu_percent_of_one_core": 0.1917,+ "wakeups_per_s": 21.4,+ "voluntary_per_s": 21.3,+ "nonvoluntary_per_s": 0.1,+ "rss_kb": 75728,+ "hwm_kb": 75728,+ "rss_anon_kb": 44840,+ "rss_file_kb": 30888,+ "anon_hugepages_kb": 0,+ "threads": 82,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-rt",+ "cpu_ticks": 11,+ "threads": 3,+ "cpu_percent_of_one_core": 0.092+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 5,+ "threads": 1,+ "cpu_percent_of_one_core": 0.042+ },+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 2,+ "threads": 1,+ "cpu_percent_of_one_core": 0.017+ }+ ],+ "loadavg_start": [+ "3.79",+ "9.24",+ "13.24"+ ]+ },+ "per_index_rss_kb": 63.3+}\ No newline at end of filediff --git a/benchmarks/idle-budget/results/result-p1024-before-32cpu-n450.json b/benchmarks/idle-budget/results/result-p1024-before-32cpu-n450.jsonnew file mode 100644index 000000000..b5e634d48--- /dev/null+++ b/benchmarks/idle-budget/results/result-p1024-before-32cpu-n450.json@@ -0,0 +1,108 @@+{+ "label": "p1024-before-32cpu-n450",+ "date_utc": "2026-09-22T04:31:09+00:00",+ "binary": {+ "version": "xerj v1.0.0-rc.77",+ "path": "/root/1024-xerj-before-verified"+ },+ "corpus": {+ "shape": "15x30",+ "indices": 450,+ "docs_per_index": 3+ },+ "port": 9610,+ "window_s": 120.0,+ "settle_target_s": 120.0,+ "boot_ms": {+ "empty_node": 5,+ "baseline_arm": 6,+ "n_indices": 385+ },+ "wal_replay_lines_after_clean_flush": 0,+ "doc_probe_hits": 3,+ "baseline": {+ "pid": 3785747,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 14,+ "cpu_percent_of_one_core": 0.1167,+ "wakeups_per_s": 23.7,+ "voluntary_per_s": 23.6,+ "nonvoluntary_per_s": 0.1,+ "rss_kb": 84728,+ "hwm_kb": 86360,+ "rss_anon_kb": 49880,+ "rss_file_kb": 34848,+ "anon_hugepages_kb": 0,+ "threads": 340,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 7,+ "threads": 1,+ "cpu_percent_of_one_core": 0.058+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 3,+ "threads": 1,+ "cpu_percent_of_one_core": 0.025+ },+ {+ "comm": "xerj-rt",+ "cpu_ticks": 2,+ "threads": 1,+ "cpu_percent_of_one_core": 0.017+ }+ ],+ "loadavg_start": [+ "4.41",+ "6.60",+ "9.60"+ ]+ },+ "measurement": {+ "pid": 3787938,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 92,+ "cpu_percent_of_one_core": 0.7665,+ "wakeups_per_s": 22.6,+ "voluntary_per_s": 22.0,+ "nonvoluntary_per_s": 0.6,+ "rss_kb": 174280,+ "hwm_kb": 174280,+ "rss_anon_kb": 136712,+ "rss_file_kb": 37568,+ "anon_hugepages_kb": 0,+ "threads": 336,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-rt",+ "cpu_ticks": 72,+ "threads": 2,+ "cpu_percent_of_one_core": 0.6+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 14,+ "threads": 1,+ "cpu_percent_of_one_core": 0.117+ },+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 5,+ "threads": 1,+ "cpu_percent_of_one_core": 0.042+ }+ ],+ "loadavg_start": [+ "19.40",+ "9.62",+ "10.08"+ ]+ },+ "per_index_rss_kb": 199.0+}\ No newline at end of filediff --git a/benchmarks/idle-budget/results/result-p1024-n150-4cpu.json b/benchmarks/idle-budget/results/result-p1024-n150-4cpu.jsonnew file mode 100644index 000000000..f050f07af--- /dev/null+++ b/benchmarks/idle-budget/results/result-p1024-n150-4cpu.json@@ -0,0 +1,108 @@+{+ "label": "p1024-n150-4cpu",+ "date_utc": "2026-09-22T02:07:54+00:00",+ "binary": {+ "version": "xerj v1.0.0-rc.77",+ "path": "/root/xerj-1024/engine/target/ci-test/xerj"+ },+ "corpus": {+ "shape": "5x30",+ "indices": 150,+ "docs_per_index": 3+ },+ "port": 9610,+ "window_s": 120.0,+ "settle_target_s": 120.0,+ "boot_ms": {+ "empty_node": 5,+ "baseline_arm": 5,+ "n_indices": 5+ },+ "wal_replay_lines_after_clean_flush": 0,+ "doc_probe_hits": 3,+ "baseline": {+ "pid": 3557147,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 8,+ "cpu_percent_of_one_core": 0.0667,+ "wakeups_per_s": 24.6,+ "voluntary_per_s": 24.6,+ "nonvoluntary_per_s": 0.0,+ "rss_kb": 46820,+ "hwm_kb": 46820,+ "rss_anon_kb": 18396,+ "rss_file_kb": 28424,+ "anon_hugepages_kb": 0,+ "threads": 82,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 3,+ "threads": 1,+ "cpu_percent_of_one_core": 0.025+ },+ {+ "comm": "xerj-rt",+ "cpu_ticks": 1,+ "threads": 1,+ "cpu_percent_of_one_core": 0.008+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 1,+ "threads": 1,+ "cpu_percent_of_one_core": 0.008+ }+ ],+ "loadavg_start": [+ "2.41",+ "4.76",+ "13.12"+ ]+ },+ "measurement": {+ "pid": 3565059,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 10,+ "cpu_percent_of_one_core": 0.0833,+ "wakeups_per_s": 24.6,+ "voluntary_per_s": 24.6,+ "nonvoluntary_per_s": 0.0,+ "rss_kb": 77556,+ "hwm_kb": 77556,+ "rss_anon_kb": 46500,+ "rss_file_kb": 31056,+ "anon_hugepages_kb": 0,+ "threads": 82,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-rt",+ "cpu_ticks": 3,+ "threads": 2,+ "cpu_percent_of_one_core": 0.025+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 2,+ "threads": 1,+ "cpu_percent_of_one_core": 0.017+ },+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 1,+ "threads": 1,+ "cpu_percent_of_one_core": 0.008+ }+ ],+ "loadavg_start": [+ "2.01",+ "3.72",+ "11.55"+ ]+ },+ "per_index_rss_kb": 204.9+}\ No newline at end of filediff --git a/benchmarks/idle-budget/results/result-p1024-n450-4cpu.json b/benchmarks/idle-budget/results/result-p1024-n450-4cpu.jsonnew file mode 100644index 000000000..ee951d380--- /dev/null+++ b/benchmarks/idle-budget/results/result-p1024-n450-4cpu.json@@ -0,0 +1,102 @@+{+ "label": "p1024-n450-4cpu",+ "date_utc": "2026-09-22T02:03:25+00:00",+ "binary": {+ "version": "xerj v1.0.0-rc.77",+ "path": "/root/xerj-1024/engine/target/ci-test/xerj"+ },+ "corpus": {+ "shape": "15x30",+ "indices": 450,+ "docs_per_index": 3+ },+ "port": 9610,+ "window_s": 120.0,+ "settle_target_s": 120.0,+ "boot_ms": {+ "empty_node": 5,+ "baseline_arm": 5,+ "n_indices": 6+ },+ "wal_replay_lines_after_clean_flush": 0,+ "doc_probe_hits": 3,+ "baseline": {+ "pid": 3555313,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 7,+ "cpu_percent_of_one_core": 0.0583,+ "wakeups_per_s": 24.6,+ "voluntary_per_s": 24.6,+ "nonvoluntary_per_s": 0.1,+ "rss_kb": 47828,+ "hwm_kb": 47828,+ "rss_anon_kb": 18240,+ "rss_file_kb": 29588,+ "anon_hugepages_kb": 0,+ "threads": 82,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 3,+ "threads": 1,+ "cpu_percent_of_one_core": 0.025+ },+ {+ "comm": "xerj-rt",+ "cpu_ticks": 1,+ "threads": 1,+ "cpu_percent_of_one_core": 0.008+ }+ ],+ "loadavg_start": [+ "2.47",+ "8.06",+ "16.79"+ ]+ },+ "measurement": {+ "pid": 3556542,+ "window_s": 120.0,+ "clk_tck": 100,+ "cpu_ticks": 27,+ "cpu_percent_of_one_core": 0.225,+ "wakeups_per_s": 25.2,+ "voluntary_per_s": 25.1,+ "nonvoluntary_per_s": 0.1,+ "rss_kb": 139504,+ "hwm_kb": 139504,+ "rss_anon_kb": 108220,+ "rss_file_kb": 31284,+ "anon_hugepages_kb": 0,+ "threads": 82,+ "fds": 15,+ "per_thread_cpu": [+ {+ "comm": "xerj-rt",+ "cpu_ticks": 11,+ "threads": 3,+ "cpu_percent_of_one_core": 0.092+ },+ {+ "comm": "xerj-memtable-s",+ "cpu_ticks": 8,+ "threads": 1,+ "cpu_percent_of_one_core": 0.067+ },+ {+ "comm": "xerj-mem-sample",+ "cpu_ticks": 5,+ "threads": 1,+ "cpu_percent_of_one_core": 0.042+ }+ ],+ "loadavg_start": [+ "2.40",+ "6.04",+ "14.73"+ ]+ },+ "per_index_rss_kb": 203.7+}\ No newline at end of filediff --git a/engine/crates/xerj-engine/src/index.rs b/engine/crates/xerj-engine/src/index.rsindex 1cf6cb246..f4e9c9ddc 100644--- a/engine/crates/xerj-engine/src/index.rs+++ b/engine/crates/xerj-engine/src/index.rs@@ -7896,15 +7896,24 @@ pub struct EnrichTable {/// Behaviour:/// * `record(hash)` returns `true` on first sight (miss), `false` on/// repeat (hit).-/// * Capacity is fixed at construction. Inserting at capacity evicts+/// * The bound is fixed at construction. Inserting at the bound evicts/// the oldest entry (true FIFO, not LRU — LRU would need a per-hit/// reorder which is overkill for a hit-count metric)./// * `O(1)` for both insert and membership; bounded memory at/// `cap * (size_of::<u64>() + small overhead)`.+/// * Allocates NOTHING at construction (#1024): both collections start+/// empty and grow on first `record`. The previous `with_capacity(cap)`+/// constructor pre-wrote a 131,072-bucket hash table plus a 512 KiB+/// deque ring — ~136 kB resident per index before the index had ever+/// served a query, which made it the single largest constant+/// per-index idle cost (~136 of the measured ~205 kB/idx on the+/// idle-budget fixture). An index now pays for the seen-set only once+/// it actually tracks a `request_cache=true` search; a busy index+/// converges to the same bounded footprint as before.///-/// 65 536 entries (the default) is ~1.5 MiB; comfortable headroom for-/// the working set of a typical query pattern, small enough to never-/// matter even on tiny VMs.+/// 65 536 entries (the default) is ~1.5 MiB at steady state; comfortable+/// headroom for the working set of a typical query pattern, small enough+/// to never matter even on tiny VMs.pub(crate) struct RequestCacheSeen {set: std::collections::HashSet<u64>,order: std::collections::VecDeque<u64>,@@ -7912,11 +7921,17 @@ pub(crate) struct RequestCacheSeen {}impl RequestCacheSeen {- pub fn with_capacity(cap: usize) -> Self {+ /// Idle-empty construction: `cap` is only the FIFO bound — no table,+ /// no ring until the first `record`. Pay-per-use, the same shape+ /// quickwit gives its per-split reader stack by opening it inside the+ /// leaf-search future (quickwit-search/src/leaf.rs+ /// `open_index_with_caches`, Apache-2.0) — design adapted, no code+ /// copied.+ pub fn new(cap: usize) -> Self {let cap = cap.max(1);Self {- set: std::collections::HashSet::with_capacity(cap),- order: std::collections::VecDeque::with_capacity(cap),+ set: std::collections::HashSet::default(),+ order: std::collections::VecDeque::default(),cap,}}@@ -7937,6 +7952,140 @@ impl RequestCacheSeen {}}+#[cfg(test)]+mod request_cache_seen_idle_tests {+ use super::*;++ fn text_schema() -> Schema {+ let mut schema = Schema::empty();+ schema+ .add_field(FieldConfig::new("body", FieldType::Text))+ .unwrap();+ schema+ }++ /// #1024 — the seen-set was `HashSet/VecDeque::with_capacity(65_536)` at+ /// both `Index` construction sites: a 131,072-bucket hash table plus a+ /// 512 KiB deque ring, ~136 kB resident per index, written before the+ /// index has ever served a query. That is the single largest constant+ /// per-index idle allocation (~136 of the measured ~205 kB/idx). An+ /// index that has never tracked a request_cache search must hold none+ /// of it: the collections start empty and grow on first `record`.+ #[tokio::test(flavor = "multi_thread", worker_threads = 2)]+ async fn created_index_allocates_no_request_cache_seen_set() {+ let dir = tempfile::tempdir().unwrap();+ let mut config = Config::default();+ config.server.data_dir = dir.path().to_string_lossy().into_owned();+ let engine = crate::Engine::new(config).unwrap();+ engine+ .create_index("rc-idle-create", text_schema())+ .unwrap();+ let idx = engine.get_index("rc-idle-create").unwrap();+ idx.abort_background_tasks();+ let seen = idx.request_cache_seen.read().await;+ assert_eq!(+ seen.set.capacity(),+ 0,+ "seen-set hash table must not exist before the first tracked search"+ );+ assert_eq!(+ seen.order.capacity(),+ 0,+ "seen-set FIFO ring must not exist before the first tracked search"+ );+ }++ /// Same pin on the boot path (`Engine::new` → `Index::open`): the+ /// idle-RSS fixture restarts a cleanly-flushed corpus of N indexes, none+ /// of which have served a request_cache=true search — every one of them+ /// must come back up with an unallocated seen-set. The document assert+ /// doubles as the boot-correctness pin: laziness must not lose data.+ #[tokio::test(flavor = "multi_thread", worker_threads = 2)]+ async fn reopened_index_allocates_no_request_cache_seen_set() {+ let dir = tempfile::tempdir().unwrap();+ let mut config = Config::default();+ config.server.data_dir = dir.path().to_string_lossy().into_owned();+ let engine = crate::Engine::new(config.clone()).unwrap();+ engine+ .create_index("rc-idle-reopen", text_schema())+ .unwrap();+ let idx = engine.get_index("rc-idle-reopen").unwrap();+ idx.abort_background_tasks();+ idx.index_document(Some("one".into()), serde_json::json!({"body": "alpha"}))+ .await+ .unwrap();+ drop(idx);+ drop(engine);++ let reopened = crate::Engine::new(config).unwrap();+ let idx = reopened.get_index("rc-idle-reopen").unwrap();+ idx.abort_background_tasks();+ assert!(+ idx.get_document("one").await.unwrap().is_some(),+ "reopened index must still serve its document"+ );+ let seen = idx.request_cache_seen.read().await;+ assert_eq!(+ seen.set.capacity(),+ 0,+ "boot-opened idle index must not allocate the seen-set hash table"+ );+ assert_eq!(+ seen.order.capacity(),+ 0,+ "boot-opened idle index must not allocate the seen-set FIFO ring"+ );+ }++ /// Laziness must not change the hit/miss contract: first sight = miss,+ /// repeat = hit, and the FIFO bound still evicts the oldest entry once+ /// `cap` distinct hashes have been recorded — including when the+ /// collections grew from empty instead of being pre-sized.+ #[tokio::test(flavor = "multi_thread", worker_threads = 2)]+ async fn track_request_cache_dedupes_and_evicts_when_lazily_grown() {+ let dir = tempfile::tempdir().unwrap();+ let mut config = Config::default();+ config.server.data_dir = dir.path().to_string_lossy().into_owned();+ let engine = crate::Engine::new(config).unwrap();+ engine.create_index("rc-idle-track", text_schema()).unwrap();+ let idx = engine.get_index("rc-idle-track").unwrap();+ idx.abort_background_tasks();++ idx.track_request_cache(1);+ idx.track_request_cache(1);+ assert_eq!(idx.request_cache_miss_count(), 1);+ assert_eq!(idx.request_cache_hit_count(), 1);+ {+ // The first record is what materialises the collections.+ let seen = idx.request_cache_seen.read().await;+ assert!(seen.set.capacity() > 0, "set must grow on first record");+ assert!(+ seen.order.capacity() > 0,+ "FIFO ring must grow on first record"+ );+ assert_eq!(seen.order.len(), 1);+ }++ // Fill to the production cap (65_536 distinct hashes) plus one, so+ // the oldest (hash 1) is evicted; re-recording it is a miss again,+ // while the newest is still a hit.+ for h in 2..=65_537u64 {+ idx.track_request_cache(h);+ }+ assert_eq!(idx.request_cache_miss_count(), 65_537);+ assert_eq!(idx.request_cache_hit_count(), 1);+ idx.track_request_cache(1); // evicted by the FIFO bound → miss+ idx.track_request_cache(65_537); // still resident → hit+ assert_eq!(idx.request_cache_miss_count(), 65_538);+ assert_eq!(idx.request_cache_hit_count(), 2);+ {+ // Bounded at cap even though growth was incremental.+ let seen = idx.request_cache_seen.read().await;+ assert_eq!(seen.order.len(), 65_536);+ }+ }+}+// ── SQ8 serving-path codec ────────────────────────────────────────────────────/// L2-normalise a vector in place (no-op for a zero vector). Used for cosine@@ -8910,7 +9059,7 @@ impl Index {test_merge_repoint_ready: Arc::new(AtomicBool::new(false)),doc_count: Arc::new(AtomicU64::new(0)),noop_update_count: Arc::new(AtomicU64::new(0)),- request_cache_seen: Arc::new(RwLock::new(RequestCacheSeen::with_capacity(65_536))),+ request_cache_seen: Arc::new(RwLock::new(RequestCacheSeen::new(65_536))),request_cache_hits: Arc::new(AtomicU64::new(0)),request_cache_misses: Arc::new(AtomicU64::new(0)),query_cache_hits: Arc::new(AtomicU64::new(0)),@@ -9383,7 +9532,7 @@ impl Index {test_merge_repoint_ready: Arc::new(AtomicBool::new(false)),doc_count: Arc::new(AtomicU64::new(total_doc_count)),noop_update_count: Arc::new(AtomicU64::new(0)),- request_cache_seen: Arc::new(RwLock::new(RequestCacheSeen::with_capacity(65_536))),+ request_cache_seen: Arc::new(RwLock::new(RequestCacheSeen::new(65_536))),request_cache_hits: Arc::new(AtomicU64::new(0)),request_cache_misses: Arc::new(AtomicU64::new(0)),query_cache_hits: Arc::new(AtomicU64::new(0)),