0b6e1bc5
bench: add map_bench.lua, close ch2 (intervention regresses)
ch2 hypothesized that replacing `for k, v in pairs(map_value) do` in
the codegen-emitted map encoder with a key-collect + ipairs pattern
would let the inner emit loop stay on a JIT trace. Hand-implemented in
both codegen (inline.go:emitInlineEncodeMap) and runtime
(codec.lua kind=='map' branch); 752/752 tests passed.
Bench (work.lab.local, median of 3, Person.ages_by_nickname encode):
map size | BEFORE | AFTER | Δ
1 | 1,282,180 | 1,128,545 | -12%
3 | 634,880 | 549,761 | -13%
10 | 215,745 | 196,800 | -9%
50 | 48,162 | 45,614 | -5%
200 | 11,613 | 11,282 | -3%
Regression across all sizes. LuaJIT's side-trace machinery was already
JIT-ing the inner body via a side trace from the pairs() ISNEXT abort
point — the body was already on-trace before. The change just adds
wrapper overhead (scratch table alloc, O(N) key-collection, extra hash
lookup per entry).
Reverted the codegen + runtime edits. Keeping bench/map_bench.lua —
useful harness for any future map-encoder work (e.g. x9f deterministic
ordering may revisit this).
See ch2 bd notes for full diagnosis.
Eugene Blikh <bigbes@gmail.com> — 2026-05-24 17:05:47 UTC
Commit 0b6e1bc52ef675919ba245e012538e615d17afa1 —
view raw patch
Parent(s):
035b2adb
| File | Status | + | − |
|---|---|---|---|
.beads/interactions.jsonl
|
M | +1 | |
.beads/issues.jsonl
|
M | +3 | -3 |
bench/map_bench.lua
|
A | +52 |