Skip to content

perf(encoding): count packed varints eight bytes at a time - #780

Open
fallintoplace wants to merge 3 commits into
anthropics:mainfrom
fallintoplace:perf/packed-varint-count-wordwise-20261019
Open

fallintoplace wants to merge 3 commits into
anthropics:mainfrom
fallintoplace:perf/packed-varint-count-wordwise-20261019

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

What

Count packed varint terminators eight bytes at a time for large inputs.

Why

The view decoder scans packed payloads just to reserve the element list.

Implementation

Keep the scalar counter below 64 bytes. Use portable u64 loads and popcount above that. Add boundary cases and an opt-in Criterion benchmark.

Benchmark

64 KiB: 1.32 μs vs 10.55 μs scalar (~8× faster). 256 B: 6.31 ns vs 42.13 ns (~6.7×). 50 Criterion samples.

@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