2ffc6ebd
wkt: split length-prefix emission to drop per-field concat
Apply the split-emit pattern from ac9b9c1 (inline.go + codec.lua) to the WKT hand-rolled encoders. Replace `wire.encode_len(body)` — which allocates `varint(#body) .. body` — with three out slots (tag, varint length, body) wherever the result feeds a `table.concat(out)` accumulator. For StringValue/BytesValue (whose encoders return a single string and can't be split), inline encode_len's chain so LuaJIT folds tag + varint + body into one multi-concat instead of two sequential concats. Same final wire bytes. Touched sites: struct_encode (split the outer entry wrap, inline the inner key/value chain), list_encode, any_encode (type_url, value), fieldmask_encode, and the WRAPPERS LEN-typed encoders. The struct_encode inner entry stays a single chain rather than fanning out into more `out` slots — eight slots per Struct entry regressed B/op and gave no encode win on the wkt-event shape; three slots match the codec.lua nested-message pattern and land the speedup. bench/shapes (wkt-event encode, median across 4 runs): full: 125895 -> 129000 msgs/s (+2.5%) runtime: 115231 -> 120000 msgs/s (+4%) make test 509/509, make jit-trace 23/23, docker conformance binary 1478/0 (unexpected), text suite clean.
Eugene Blikh <bigbes@gmail.com> — 2026-05-16 15:57:15 UTC
Commit 2ffc6ebd58b1eb374c43e75566a3fecb1cbf20ef —
view raw patch
Parent(s):
51f19633
| File | Status | + | − |
|---|---|---|---|
runtime/pb/wkt.lua
|
M | +32 | -10 |