~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Frames as bytes, and a fast check in place of SHA-256: a change of the logs' and tables' format

Closed
Closed chadtmiller.com opened this issue 0 comments

The store benchmark (bench/store/RESULTS.md, the runner) gives what each is worth:

as it ischanged
bytes of a commit in its log11952 (JSON, bytes as hex)5944 (bytes as bytes)
a log replayed, commits a second84 thousand274 thousand
writes with no sync, 16 writers, a second55 thousand259 thousand
a firehose replayed from one log, events a second276 thousand (SHA-256)1.10 million (XXH3-64), 1.07 million (CRC32C)
a record not in the cache, 4 KiB blocks, file open, µs11.1 (SHA-256)8.0 (XXH3-64), 8.1 (CRC32C)
a listing of 50 not in the cache, µs223162

With every commit synced, on the runner's disk, neither changes the rate of writes: a commit's time is its sync. BLAKE3 is slower than SHA-256 at these sizes.

What stands in the way

  • A log has no version: no header, no flag in a frame, and its seal is a frame of JSON recognised by parsing it. A frame whose check fails or whose payload is no JSON array ends a replay and is cut off as a torn tail (Wal::open, open_log_with). So a reader must know a frame of each format before it calls one torn, and the release before, run on a data directory this one wrote, would cut the new frames off. spec/STORE.md lets a version refuse a later one's data directory; it must refuse, not cut.
  • The server reads items out of frames by position (Pos, skim, index, Want in checkpoint.rs): the offsets are of JSON text (hex of tree nodes and event frames, a record's JSON, a space commit's operations). A frame of bytes must keep each item's range addressable.
  • Fold hands frames on as Vec<Vec<Json>>; compact::legacy_header tells an old service checkpoint from a table by the SHA-256 check.
  • A table's only version is its footer's magic, PDSTAB01; its blocks, index and bloom filter each carry the SHA-256 check, and the filter's hashes are SHA-256 of the key.
  • The tests that cut a log at every byte and kill a compaction at every step are what a new format must pass in both formats and across them.

Order suggested

The check first, for tables alone (a new footer magic, the old read as before): it is the smaller change and the cold reads are what it buys. Then frames, with a version a start reads before it cuts anything.