Skip to content

perf(decode): avoid zeroing unknown payload buffers - #783

Open
fallintoplace wants to merge 1 commit into
anthropics:mainfrom
fallintoplace:perf/unknown-length-copy-20261019
Open

fallintoplace wants to merge 1 commit into
anthropics:mainfrom
fallintoplace:perf/unknown-length-copy-20261019

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

What

  • Copy unknown length-delimited fields into their final allocation.

Why

  • The decoder currently zeroes the buffer, then overwrites the same bytes.

Implementation

  • Copy contiguous payloads once and copy fragmented Buf chunks into the same allocation.
  • Add edge-case coverage and an opt-in Criterion benchmark.

Benchmark

  • Criterion, 40 samples: 4 KiB decode went from 135 ns to 100 ns contiguous and 134 ns to 95 ns split. 32 B contiguous stayed near 36 ns; split was 3.7% slower.

@github-actions

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant