refactor: call the benchmark's comparison the legacy format

The README, a comment in :Reflect and tests/Benchmark named the project
whose transaction log this library replaces. That name means nothing to
people using the library, so the benchmark's reference implementation is
now the `Legacy` namespace, its column reads `legacy ms`, and the prose
describes it as the hand-rolled iostream format Crafter.DB replaces.
Timings and logic are unchanged; the suite still passes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-10-31 20:51:14 +01:00
commit eb720058f5
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
3 changed files with 33 additions and 33 deletions

View file

@ -1,6 +1,6 @@
# Crafter.DB
An embedded, typed table store for C++26: a table is a plain struct, a file is a memory-mapped array of fixed-width rows, queries are C++. Built for the Catcrafts projects (it replaces Nostro's hand-rolled transaction log) and distributed as one C++ module, `Crafter.DB`.
An embedded, typed table store for C++26: a table is a plain struct, a file is a memory-mapped array of fixed-width rows, queries are C++. Built for the Catcrafts projects (it replaces a hand-rolled, iostream-based transaction log) and distributed as one C++ module, `Crafter.DB`.
- **Structs are the schema.** Any aggregate with a `version` is a table. No macros, no registration, no code generation: member names, types and offsets are derived at compile time.
- **Fixed-width rows, out-of-line strings.** Every row is `rowSize` bytes. Strings and blobs live in a heap region; the row holds a 16-byte handle that keeps values of up to 12 bytes, and the first 4 bytes of longer ones, inline, so `iban == x` is one 8-byte compare per row.
@ -194,18 +194,18 @@ One file per table: a 4 KiB header (magic, format and schema version, fingerprin
## Performance
`tests/Benchmark` compares Crafter.DB with a cleaned-up copy of Nostro's format (iostream, 2-byte length-prefixed strings) on 100 000 transactions, warm cache, one run on a Xeon w7-3465X:
`tests/Benchmark` compares Crafter.DB with a cleaned-up copy of the legacy format it replaces (iostream, 2-byte length-prefixed strings, linear scans) on 100 000 transactions, warm cache, one run on a Xeon w7-3465X:
| Operation | Nostro | Crafter.DB | Note |
| Operation | Legacy | Crafter.DB | Note |
| --- | --- | --- | --- |
| append 100 000 rows | 16.5 ms | 11.1 ms | Crafter.DB includes `fdatasync`; Nostro syncs nothing |
| append 100 000 rows | 16.5 ms | 11.1 ms | Crafter.DB includes `fdatasync`; the legacy format syncs nothing |
| last timestamp, 1000 × open + read | 1.9 ms | 30.0 ms | opening a mapped table costs one `mmap` per extent (about 20 for this size); open once per process |
| load all, materialised | 36.0 ms | 10.4 ms | zero-copy scan of two columns: 0.8 ms |
| time range, 10 % of rows | 10.0 ms | 0.9 ms | binary search + contiguous slice |
| `iban == x` | 16.2 ms | 0.23–0.30 ms | 2–3 ns per row |
| time range + `iban == x` | 11.2 ms | 0.03 ms | |
File size for that table: 17.2 MB against Nostro's 9.3 MB (fixed-width handles plus the slack of the last extents; `Compact()` right-sizes).
File size for that table: 17.2 MB against the legacy format's 9.3 MB (fixed-width handles plus the slack of the last extents; `Compact()` right-sizes).
## Building