Repository navigation
txtpbfmt: move descriptor file loading into the fmt command - #196
Merged
copybara-service[bot] merged 1 commit intoSep 16, 2026
Merged
Conversation
Importing parser pulled in protodesc and descriptorpb via impl's use of the descriptor package, costing about 3 MB of binary size even though the loading only happens when SortFieldsByFieldNumber is set. The guard is a runtime condition, so the linker cannot drop the descriptor runtime. Config now carries an already-resolved RootMessageDescriptor rather than a descriptor file path and message name, and cmd/txtpbfmt resolves the -proto_descriptor and -message_full_name flags into one. impl keeps its cheap protoreflect import and loses the expensive ones, and the library no longer reads files on the caller's behalf. A hello-world binary importing parser drops from 7,966,362 to 3,091,409 bytes. Fixes protocolbuffers#195.
Member
|
Thanks, I'm fixing the internal users. |
Contributor
Author
|
Thanks very much! |
mvdan
added a commit
to cue-lang/cue
that referenced
this pull request
Sep 17, 2026
encoding/protobuf/textproto is our only txtpbfmt consumer, and it parses and prints text protos without a schema. Even so we linked the entire protobuf runtime, because txtpbfmt/impl imported txtpbfmt/descriptor to load descriptor set files, which pulled in protodesc, protoregistry, descriptorpb, prototext and the rest. protocolbuffers/txtpbfmt#196 moved that loading into txtpbfmt's own fmt command, leaving the library needing just the protoreflect interfaces. Twenty-seven packages drop out of the cmd/cue build, and a release build as internal/ci/goreleaser produces it (CGO_ENABLED=0, -trimpath, -ldflags="-s -w") goes from 26,366,112 to 24,522,912 bytes, 1,843,200 fewer or -7.0%. Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Change-Id: I80a2053d907654d8d7cd2e05948306311c0148f9 GitOrigin-RevId: 0dc732511f01b4dd5baf9b5b18cc70f684172256
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.
(see commit message)
Fixes #195.