Skip to content

Add benchmark/performance-comparison.md and the benchmarks that produced its numbers - #600

Merged
nockawa merged 1 commit into
mainfrom
new-bench
Jul 29, 2026
Merged

nockawa merged 1 commit into
mainfrom
new-bench

Conversation

@nockawa

@nockawa nockawa commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

A plain-English competitive writeup against SQLite, RocksDB, LMDB and FASTER, plus what a single operation costs inside Typhon. Every figure is reproducible from this repository, and the run commands sit next to each section.

13 files, +2 071 / −118. Everything here either is the document or produced a number in it. No engine code is touched.

Why the disclaimer is at the top

Comparative benchmarks published without a method are worthless, and ours name real products. So the document states plainly that the competitor adapters were written to the best of our knowledge, may be far from optimal, and that where one is naive the number flatters Typhon — a defect in our measurement, not a property of that engine. It invites PRs against the adapters.

That is not boilerplate, and the PR proves it.

The LMDB adapter is fixed here, because it changed the published numbers

Reviewing before publishing, the adapter was found calling tx.OpenDatabase() on every batch — that is mdb_dbi_open, which takes an environment-wide lock and is documented as a startup-time call — and allocating two byte[8] per operation inside the measured loop. The handle is now opened once and shared across workers; keys and values are stackalloc.

The correction costs us:

before after
batched reads 64.9 M/s 70.6 M/s — now ahead of Typhon (66.9)
point reads 2.5 4.8
updates 2.6 4.0
range scans 214.7 421.3 — scan lead over Typhon goes 1.8× → 3.6×

Remaining known headroom is documented in the adapter rather than hidden: LMDB read transactions could be pooled with Reset()/Renew(). Not applied.

Extreme ratios deliberately not published

SQLite and LMDB both serialise writers by design. On a mixed workload a four-digit multiplier describes the workload, not the engine. Those cells give the raw figure plus a footnote explaining the design choice, and state that read-mostly or single-writer workloads are unaffected.

Also dropped: a "time to commit a transaction" row whose RocksDB/LMDB figures came from the fsync-inclusive path while everything else is no-fsync. Mixing durability tiers in one table is the error this exercise exists to remove.

Read paths are checksum-verified before any number is trusted

ReadValidationProbe (-- verify) checks every engine's read path against an analytically known checksum. The concurrent runners accumulate a checksum only to defeat dead-code elimination and never verify it — so an adapter that returned nothing, read a stale snapshot, or resolved the wrong row would post a great number and nothing would notice. All five engines pass. It is also the gate for future adapter tuning: a faster adapter that stops returning correct rows now fails loudly.

EcsAccessPathBenchmarks applies the same discipline internally — a setup-time assert proves all three full-world routes visit the same entities, otherwise the ratios between them mean nothing.

Typhon-side measurement classes

All on one shared fixture, so the figures are comparable to each other:

  • StorageModeProofBenchmarks — the mode × scope matrix behind §4
  • EcsAccessPathBenchmarks — point access vs flat cluster sweep vs cell-scoped sweep vs 3×3 neighbourhood
  • BulkLoadProfile (--bulk-load) — the four ingest routes against a real on-disk WAL. BDN could not measure this: a fresh engine per sample gave ±20 µs error on a 2.3 µs mean
  • EcsLifecycleBenchmarks — spawn/destroy/commit

ArchetypeAccessorBenchmark loses the AaBench* component and archetype declarations, which move to Ecs/EcsBenchFixtures.cs so the new classes can share them. Same namespace, no consumer changes. This is the only deletion in the PR and it is a hard compile dependency.

One result we did not expect, published anyway

BulkLoad is 3.1× faster than a naive loader — the baseline its acceptance criterion used — but 0.73× against a loader that simply batches its commits. The WAL writer already batches asynchronously, so a per-row record costs a memory copy rather than a disk write, and the end-of-session forced checkpoint costs more than the records it skips. Holds at 4 M entities.

Worth a follow-up on its own: BulkLoadSession carries a manifest pair, an exclusive engine gate, a recovery path and a documented page-leak-on-abort limitation, and currently buys nothing over commit every 8192.

Placement

benchmark/, not doc/. doc/ is the DocFx site published to doc.typhondb.io, and publishing competitive numbers there is a separate decision. benchmark/ is also outside doc-accuracy-review.yml's path filter and has no benchmark.yml trigger, so this adds no CI load.

Verification

Built from the committed state alone in a throwaway worktree — Typhon.Benchmark, Typhon.CompetitiveBenchmark and the full solution all build with zero errors.

Measured 2026-07-29 on a 7950X (16 threads, one CCD), Windows 11, .NET 10, engine revision 81e2a46.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mo2eUeYS5SW6uta72uTfyx

…ced its numbers

A plain-English competitive writeup vs SQLite, RocksDB, LMDB and FASTER, plus what a single operation costs inside Typhon. Every figure is reproducible from this repository and the run commands are given with each section.

The document opens with a disclaimer, and the disclaimer is the point. Comparative benchmarks published without a method are worthless, and ours name real products. So it states plainly that the competitor adapters were written to the best of our knowledge, may be far from optimal, and that where one is naive the number flatters Typhon. It cites the LMDB defect found and fixed before publishing as evidence that this is not boilerplate, and invites PRs against the adapters.

Deliberately not published: multipliers in the hundreds or thousands. SQLite and LMDB serialise writers by design, so a four-digit ratio on a mixed workload describes the workload rather than the engine. Those cells give the raw figure plus a footnote explaining the design choice.

LmdbConcurrentAdapter is fixed here because it changed the published numbers. It was calling tx.OpenDatabase() per batch - that is mdb_dbi_open, which takes an environment-wide lock - and allocating two byte[8] per operation inside the measured loop. The handle is now opened once and shared; keys and values are stackalloc. The correction costs us: LMDB goes 64.9 -> 70.6 M/s on batched reads (now ahead of Typhon) and 214.7 -> 421.3 on range scans, taking its scan lead from 1.8x to 3.6x.

ReadValidationProbe (-- verify) checks every engine's read path against an analytically known checksum before any number is trusted. The concurrent runners accumulate a checksum only to defeat dead-code elimination and never verify it, so an adapter that returned nothing or resolved the wrong row would post a great number unnoticed. All five engines pass. It is also the gate for further adapter tuning.

Typhon-side measurement classes, all on one shared fixture so the figures are comparable to each other:
- StorageModeProofBenchmarks - the mode x scope matrix behind section 4
- EcsAccessPathBenchmarks - point access vs flat cluster sweep vs cell-scoped sweep vs 3x3 neighbourhood, with a setup-time checksum assert proving all three full-world routes visit the same entities
- BulkLoadProfile (--bulk-load) - the four ingest routes against a real on-disk WAL. BDN could not measure this: a fresh engine per sample gave +/-20us error on a 2.3us mean
- EcsLifecycleBenchmarks - spawn/destroy/commit, source of the DestroyBatch figure

ArchetypeAccessorBenchmark loses the AaBench component and archetype declarations, which move to Ecs/EcsBenchFixtures.cs so the new classes can share them. Same namespace, no consumer changes.

Placed in benchmark/ rather than doc/ on purpose: doc/ is the DocFx site published to doc.typhondb.io, and publishing competitive numbers there is a separate decision. benchmark/ is also outside doc-accuracy-review.yml's path filter and has no benchmark.yml trigger, so this adds no CI load.

Contains one result we did not expect and publish anyway: BulkLoad is 3.1x faster than a naive loader - the baseline its acceptance criterion used - but 0.73x against a loader that simply batches its commits, because the WAL writer already batches asynchronously and the end-of-session forced checkpoint costs more than the per-row records it skips. Holds at 4M entities.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mo2eUeYS5SW6uta72uTfyx
@nockawa
nockawa merged commit af669b4 into main Jul 29, 2026
13 checks passed
@nockawa
nockawa deleted the new-bench branch July 29, 2026 16:42
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