~bigbes/tarantool-protobuf: ed383c92

codegen: inline proto2 extension writers/readers (qwt) + table.new(N,0) for packed lists (2sn)

qwt closes the proto2_basic.BenchPayload `min` bench's worst data point:
encode 1.89M → 3.30M msgs/s (+75%), decode 1.02M → 1.26M msgs/s (+23%).
Mechanism: collectExtsByExtendee groups all `extend Foo { ... }`
declarations by extendee FullName across input files; emitInlineEncode
emits one dedicated writer per extension instead of dispatching through
pb.codec.encode_field, and emitInlineDecode adds an elseif arm per
extension id straight into result._extensions[full_name]. Dynamic
extensions_list walk preserved for forward compat, gated on
#_elist > N so it pays one int compare when no runtime extension was
registered.

2sn pre-sizes packed-scalar repeated lists via table.new(N, 0) where
the count is recoverable from the LEN payload — exact (lim >> 2 or
lim >> 3) for fixed-width, upper bound (lim) for varint-packed. The
allocation is deferred into the `if wt == 2 then` branch so the
per-element fallback and non-packable types keep the bare-`{}`
alloc. Avoids u39's regression mode because the call cost is paid
once per repeated-field-first-occurrence, not per message decode.

Bench summary for hello.Person full mode: encode +3-5% across sizes,
decode +1-3% across sizes. Tests: 752/752 pure-Lua, 1043/1043 with
PB_ENABLE_C=1, JIT 37/37. PERF_LOG entry covers the rationale and
caveats.

Eugene Blikh <bigbes@gmail.com> — 2026-05-24 10:55:23 UTC

Commit ed383c9288055385f17c848de41e0aa7a2089dc4view raw patch

Parent(s): 578ed4c9

23 changed file(s)

FileStatus+
.beads/interactions.jsonl M +2
.beads/issues.jsonl M +3 -3
bench/PERF_LOG.md M +85
cmd/protoc-gen-tarantool/internal/gen/gen.go M +54 -1
cmd/protoc-gen-tarantool/internal/gen/inline.go M +397 -38
examples/expected/full/c_int64/c_int64_pb.lua M +1 -14
examples/expected/full/c_nested/c_nested_pb.lua M +1 -70
examples/expected/full/c_repeated/c_repeated_pb.lua M +49 -52
examples/expected/full/conformance/conformance_pb.lua M +1 -70
examples/expected/full/hello/hello_pb.lua M +5 -86
examples/expected/full/proto2_basic/proto2_basic_pb.lua M +55 -138
examples/expected/full/protobuf_test_messages/proto2/test_messages_proto2_pb.lua M +246 -372
examples/expected/full/protobuf_test_messages/proto3/test_messages_proto3_pb.lua M +173 -156
examples/expected/full/quickstart/quickstart_pb.lua M +1 -14
examples/expected/runtime/c_int64/c_int64_pb.lua M +1
examples/expected/runtime/c_nested/c_nested_pb.lua M +1
examples/expected/runtime/c_repeated/c_repeated_pb.lua M +1
examples/expected/runtime/conformance/conformance_pb.lua M +1
examples/expected/runtime/hello/hello_pb.lua M +1
examples/expected/runtime/proto2_basic/proto2_basic_pb.lua M +1
examples/expected/runtime/protobuf_test_messages/proto2/test_messages_proto2_pb.lua M +1
examples/expected/runtime/protobuf_test_messages/proto3/test_messages_proto3_pb.lua M +1
examples/expected/runtime/quickstart/quickstart_pb.lua M +1