Commit Graph
1 Commits
Author SHA1 Message Date
yetone d7b42fcf23 usage: a chunk's one-byte numbers are read without Uvarint's loop, and a copying pass keeps its decode buffer (#4372)
A pass over packed chunks decodes every row's ~40 varints, and most are
under 128. binary.Uvarint was 42% of a lent pass's CPU on mote; take
now reads a one-byte number itself. A pass that copies its strings
(visitBlocks, rowsOf, within, the Codex pairs) decoded into a sync.Pool
buffer, which each collection empties, so after one it made the buffer
again and grew it to the largest block. It now decodes into its
rowBuffer's, as a lent pass does; unpackReusing takes the buffer and
whether its strings are lent apart.

Run on mote (M5 Pro), BenchmarkChunkRowsPass, 40 chunks of 3000 rows,
4 runs each, base 43d442700 and this change alternating twice (mote at
high load, so the lowest of each):
- lent: 16.3 ms at base, 13.0 ms here.
- copied: 55.7 and 55.1 ms; rowChunk.row's Record is most of it.
- copied after a collection: 3.34 MB and 45 allocs a pass at base,
  2.95 MB and 40 here.
- TestCopiedPassKeepsItsDecodeBuffer: red at base ("made 8
  allocations, want 4"), ok here.
- go test ./internal/usage: ok. go vet; GOOS=windows and GOOS=linux
  go vet ./internal/usage: ok. gofmt -l: clean.

Not done: a pass still decodes every chunk again; keeping them decoded
holds the history unpacked, which packing is there to avoid.
2026-11-01 18:19:53 +08:00