~bigbes/tarantool-protobuf: 89cc5008

codec: specialize writers for repeated fields (+20–80% encode across sizes)

Extends compile_writers to handle repeated scalar (packed and unpacked),
repeated message, and repeated enum (packed and unpacked). Each writer
knows its tag bytes, encoder function, and packed/unpacked shape; the
encode_message loop calls them directly without rediscovering the field
shape on every iteration.

Combined with the singular-field writers (previous commit), this lifts
runtime-mode encode throughput uniformly:

  runtime/10B   encode:  5.0 →  9.1 MB/s  (+82%)
  runtime/100B  encode:   48 →   82 MB/s  (+70%)
  runtime/1KB   encode:   50 →   69 MB/s  (+39%)
  runtime/10KB  encode:   87 →  101 MB/s  (+16%)
  runtime/100KB encode:   90 →  111 MB/s  (+22%)

  full mode encode: +10% on small sizes, +10% on large (small bonus from
                    nested encode_msg calls going through writers too)
  decode: small uplift on full mode 100B (323 → 340 MB/s), noise on rest
  alloc/op: unchanged (bench-compare clean)
  bridges across 10 jit-trace runs: 7 → 3 (-57%; total -89% from baseline)

Falls through to encode_field only for map fields and oneof branches —
both keep their existing dispatch path.

Eugene Blikh <bigbes@gmail.com> — 2026-05-15 11:01:45 UTC

Commit 89cc50084e0fd47c6a9bddfe749a5a5284730849view raw patch

Parent(s): 8014163c

1 changed file(s)

FileStatus+
runtime/pb/codec.lua M +95 -3