cubelinux: read the store where it lies, instead of rebuilding it per call

Every read began by reading the whole device into kernel memory, parsing every
record of every space into a merged pool, and heapsorting the lot — then throwing
all of it away. So a `get` of one record cost as much as listing the store, every
batch of a listing paid it again, and the coordinate bought nothing mechanically:
knowing where a record is did not make reaching it any cheaper. Measured on the
workhorse: one `get` 110 ms, one `spaces` call 119 ms, one 6,127-record listing
1,206 ms.

The records are already in the order the coordinate computes — a checkpoint writes
them by (space, key) — so the kernel now walks them where they lie: zero-copy
values, no pool, no sort, and the log (small, and the only thing that can override
the image) consulted as an overlay. It reads the image and the log window rather
than the whole device, which is four images wide.

  * `get` — the log's newest word on the coordinate, else the image walked to it.
  * `enum` — one merge pass over two sorted sequences: the space's image records
    and its log edits.
  * `spaces` — from a table of where each space starts, cached by the control
    block's generation. That table is one entry per space, not per record, and a
    checkpoint is the only thing that invalidates it.
  * `put`/`del`/`sync` — unchanged: a write is a log append, and the fold still
    writes the whole sorted store.

Verified: verify-enum.sh (a 3,006-record listing identical to userspace's, record
for record) and verify-frontend.sh (socket -> front-end -> cube(2), including a
listing larger than one batch and the store the front-end leaves being
digest-identical to userspace's) both pass.

Not yet what it should be: listing a 10-record space in a 20,000-record store
still costs about six times what it costs in a 500-record one, so the space table
is not taking effect as intended and the lookup is not yet independent of store
size. That belongs in the image's layout — a coordinate cannot be turned into a
byte offset in a variable-length packed list, because a record's position is the
sum of every value before it — and the fix is a format one, not a caching one.
This commit is contained in:
surface-camera-build
2026-09-21 01:59:11 -04:00
parent b9a7b8d8f3
commit 56665a303e
File diff suppressed because it is too large Load Diff