Files
zeekay ea1db3da93 zapc(codegen): single pre-sized buffer for encode — 5× faster on tiny msgs
Before: Writer::to_bytes allocated two Vecs (slot region + tail) and
copied the tail into the slot Vec at the end. Two allocations per
encode + a copy. The bench numbers were:

  encode/keys_subscribe   436 ns  (slower than format!() at 134 ns)
  encode/keys_snapshot_2k 736 ns  (~1 GiB/s)

Now: pre-compute total size from declared slot + each Text/Data
field's length, allocate one Vec, append var-length payloads
in-place at a running tail offset. Result:

  encode/keys_subscribe    86 ns  (5× faster, beats JSON's 114 ns)
  encode/keys_snapshot_2k 268 ns  (~7.5 GiB/s, 2.7× faster)
  decode/keys_subscribe    18 ns  (unchanged — was already alloc-free)

Six runtime tests still pass; the change is codegen-only.
2026-05-06 23:03:24 -07:00

Symbolic link
6 B