Skip to content

fix(perf): measure the HNSW recall curve and stabilise two perf canaries - #545

Merged
MPCoreDeveloper merged 2 commits into
masterfrom
fix/session-91-perf-canary-measurement
Dec 3, 2026
Merged

MPCoreDeveloper merged 2 commits into
masterfrom
fix/session-91-perf-canary-measurement

Conversation

@MPCoreDeveloper

Copy link
Copy Markdown
Owner

What

Three measurement defects found while running every suite and every benchmark after the M2–M5 merge, fixed with evidence. No product behaviour changes; no threshold was lowered.

1. The published HNSW recall figure was one ef_search value presented as the engine's accuracy

QuickZvecTest's Z4 measured recall at the shipped default (EfSearch = 50) only, and docs/benchmarks/SHARPCOREDB_VS_ZVEC_COMPARISON.md published that point — Recall@10 = 65.5% (needs ef_search tuning) — as the engine's accuracy, while BENCHMARK_METHOD.md §Z4 specifies a curve over ef ∈ {10, 50, 100, 200, 500}.

The harness now runs that curve (20-query warm-up per point, 100 queries, recall + p50/p99) and it retires the claim:

ef_search Recall@10 p50
10 25.8% 0.079 ms
50 (default) 66.1% 0.207 ms
100 85.2% 0.462 ms
200 96.0% 0.634 ms
500 99.8% 1.330 ms

The document's Z4 section, comparison-matrix row and takeaway 5 now carry the curve.

2. FsmBenchmarks.Benchmark_PageAllocation_UnderOneMicrosecond could never pass in a fresh process

One Stopwatch around ONE Allocate(10) call: the first call pays tier-0 JIT plus first-touch, so it measured 1.060 / 1.283 / 1.124 ms in three isolated runs and failed its 1000 µs bound 3/3 — although the allocator is an O(n) scan over 100 extents. Fixed: 200 discarded warm-ups, then the median of 5 rounds × 200 allocate+free pairs. Threshold unchanged.

3. HashIndex_SELECT_WHERE_Performance_5to10xFaster was decided by one unstabilised round

Green 3/3 in isolation, but it failed inside the full Performance run at exactly 0.80x against a >= 0.8 guard — a single GC/disk stall. Fixed: 200-query warm-up, then the median of 3 rounds × 1000 queries per side. Threshold unchanged.

Verification

  • core Category=Performance: 99 total / 0 failed / 16 not executed
  • core suite: 3071 / 0 / 1 after the fixes
  • DocumentationConsistencyTests: 9 / 0
  • both fixed canaries green 3/3 and 2/2 in isolation
  • write-path gate: GATE PASSED, 8/8 capability metrics inside ×1.50 (artifacts/s93-gate-run1.txt)
  • full HNSW suite re-run after the fix: Z1 559 vec/sec @100k, Z2 K=10 p50 0.566 ms / p99 1.006 ms, Z3 1.725 → 9.033 QPS at 1 → 8 threads, Z4 as above

Session record with all suite counts, gate/dual-mode/--pk/four-engine numbers: docs/performance/WORKLOG.md, session 92.

Merging to master stays an owner action.

Z4 of QuickZvecTest measured recall at the shipped default EfSearch only, and
docs/benchmarks/SHARPCOREDB_VS_ZVEC_COMPARISON.md published that single point
(65.5%, "needs ef_search tuning") as the engine's accuracy, while
BENCHMARK_METHOD.md §Z4 specifies a curve over ef {10, 50, 100, 200, 500}. The
harness now runs that curve -- 25.8% @ 10, 66.1% @ 50, 85.2% @ 100, 96.0% @ 200
(0.634 ms p50), 99.8% @ 500 -- and the document, its matrix row and takeaway 5
carry it instead of a single parameter value.

FsmBenchmarks.Benchmark_PageAllocation_UnderOneMicrosecond timed ONE call in a
fresh process (tier-0 JIT and first-touch included) and failed its 1000 us bound
3/3 at 1.060-1.283 ms although the allocator is an O(n) scan over 100 extents;
HashIndex_SELECT_WHERE_Performance_5to10xFaster decided a >= 0.8x guard from one
unstabilised round and failed once at exactly 0.80x. Both now warm up (200
iterations / 200 queries) and publish a median of several rounds. Thresholds
unchanged -- nothing was weakened to make them pass.

Verification: core Category=Performance 99 / 0 / 16; core suite 3071 / 0 / 1;
DocumentationConsistencyTests 9 / 0; write-path gate PASSED (8/8 capability
metrics inside x1.50); the fixed canaries green 3/3 and 2/2 in isolation.
Full session record: docs/performance/WORKLOG.md, session 92.
@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…epair the harnesses

ExecuteSQL("SELECT ...") executed the query and then printed every row to
stdout, skipped only when CI/TF_BUILD/GITHUB_ACTIONS was set. Running
SharpCoreDB.Benchmarks showed what that means for a caller: 10 GB of log from a
single 100k-row insert phase, and 49 MB per minute still arriving in the read
phase. ExecuteQuery returns rows; the dump is gone. Pinned by
ExecuteSelectConsoleSilenceTests (red before, green after, rows still readable
through ExecuteQuery). Core suite 3077 / 0 / 1.

QuickZvecTest's Z4 takes the scale and the ef points as arguments now
(--recall-only, --recall-1m, --recall-scale=N, --recall-ef=a,b, --recall-m,
--recall-efc) and prints M/efc with every point, because the 1M point
BENCHMARK_METHOD.md asks for costs one rebuild per ef. Measured: 10k 96.0% at
ef=200, 100k 60.5% at M=16 vs 85.7% at M=32, 1M 19.7% at M=16 -- the M=32
control shows this is the HNSW M/ef trade-off on a uniform-random corpus, not a
broken search path.

Harness repairs, each found by running it:
- SharpCoreDB.CQRS.Benchmarks did not compile: the dispatch API moved to the
  SharpDispatch package in 2.1.0 and the project never got the reference.
- DataGenerator interpolated Score with the current culture (88,5 on nl-NL),
  which the parser correctly read as a tuple separator, and it produced 100
  distinct e-mails for 100k rows against email TEXT UNIQUE.
- The BLite scenarios ran the SQL validator inside the measurement; they open
  with SqlValidationMode.Disabled through one shared configuration.
- docs/cqrs README + QUICKSTART documented the pre-2.1.0 namespace and the
  Success/Failure member names that never existed; both now import SharpDispatch
  and use Ok/Fail.

JsonLiteralInsertTests (5 cases) pins that a double quote inside a single-quoted
literal is an ordinary character -- the rule the first BLite failure looked like
it violated, and does not.

Verification: core 3077/0/1; Server.IntegrationTests 208/0/0; the write-path gate
still PASSED; --pk profiling arms measured (INSERT 162k ops/s at 6.17 us/row
with index-maint at 24.3%; DELETE 185k ops/s with parse at 50.9%). Session 92,
addendum 2 in docs/performance/WORKLOG.md.
@sonarqubecloud

sonarqubecloud Bot commented Dec 3, 2026

Copy link
Copy Markdown

@MPCoreDeveloper
MPCoreDeveloper merged commit 68556ca into master Dec 3, 2026
14 checks passed
@MPCoreDeveloper
MPCoreDeveloper deleted the fix/session-91-perf-canary-measurement branch December 3, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant