Repository navigation
Conversation
Every JSON object decoded by fromJson allocated a Set of seen fields and a Map of seen oneofs, only to detect duplicates. A field can only be set twice in one object through two distinct keys, its proto name and its JSON name, and most messages set at most one oneof. A field whose JSON name differs from its proto name now looks up its other key in the object; the set is only created when an object holds both keys of some field. The first oneof that is set is kept in two locals, and the map is only created when a second oneof is set. The order in which keys are read and errors are raised is unchanged. 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
|
Hey! 👋 This continues the performance work discussed in #333, after the growable 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. The full history the measurement method, A/A runs to calibrate the noise, CPU profiles, a review of each change, and the raw benchmark reports is in our fork: 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.
fromJsonallocated aSetof seen fields and aMapof seen oneofs for every decoded JSON object, only to detect duplicates. Most objects need neither:This change:
hasOwnProperty. TheSetis only created when an object holds both keys of some field.Mapis only created when a second oneof is set.nulloneof scalar still counts as present;New tests cover a duplicate given by its JSON name first, an invalid first occurrence before the duplicate, and conflicts in a oneof other than the first one set.
Benchmarks
The numbers come from
packages/protobuf-bench, unchanged corpus, run on a GitHub-hosted runner (Intel Xeon Platinum 8370C, Node.js 24.5.0).All other cases of the corpus (
create,toBinary,fromBinary,toJson,BinaryWriter/*,BinaryReader/*, andfromJson/generalandfromJson/map-scalar) show no significant difference.We measured the same way on production-shaped payloads as well. The
fromJsongains are:We can share these fixtures if they are useful.
Size
from-json.jsminified (esbuild): 13,809 → 13,979 B (+170 B), gzip 4,483 → 4,534 B (+51 B). None of thebundle-sizeentry points importfromJson, so its table does not change.🤖 Generated with Claude Code
https://claude.ai/code/session_01JCd4TPygQp4GPxMsTMm2Bi