Repository navigation
Conversation
BinaryReader.string() took its bytes through bytes(), which creates a subarray view for every string, although the ASCII fast path only needs to read the bytes. It now reads them from the buffer directly; only the UTF-8 decoder, used for longer strings and for any byte above 0x7f, gets a subarray. Length, bounds check and errors are those of bytes(). Adds tests for BinaryReader.string(), which had none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JCd4TPygQp4GPxMsTMm2Bi
|
@intech is attempting to deploy a commit to the bufbuild Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
This continues the performance work discussed in #333 and implements the follow-up suggested in #1509 (running the ASCII fast path on this.buf). A note on how this was made: the code changes and the benchmarks were produced by an AI assistant under my direction, and I reviewed every step. fork PR: Connectum-Framework#28 (benchmark reports are the bot comments on that PR) benchmark tooling: Connectum-Framework#26 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the suggestion in #1509 to run the ASCII fast path on
this.buf.BinaryReader.string()read its bytes throughbytes(), which creates asubarrayview for every string. The ASCII fast path only needs to read those bytes.With this change:
bytes().BinaryReader.string()had no direct tests. The new tests cover:Benchmarks
The numbers come from
packages/protobuf-bench, unchanged corpus, run on a GitHub-hosted runner (AMD EPYC 7763, Node.js 24.5.0).No significant difference:
BinaryReader/string-utf8. Its path is essentially unchanged: these strings are longer than 32 bytes and go straight to the decoder, as before. Results per run:We measured the same way on production-shaped payloads as well. The
fromBinarygains are:We can share these fixtures if they are useful.
Size
The
bundle-sizetable is updated. For one file:wire/binary-encoding.jsminified (esbuild): 7,019 → 7,113 B (+94 B), gzip 2,331 → 2,346 B (+15 B).🤖 Generated with Claude Code
https://claude.ai/code/session_01JCd4TPygQp4GPxMsTMm2Bi