Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc-gen-go: use pointer for unknownFields #858

Open
dsnet opened this issue May 23, 2019 · 2 comments
Open

protoc-gen-go: use pointer for unknownFields #858

dsnet opened this issue May 23, 2019 · 2 comments

Comments

@dsnet
Copy link
Member

dsnet commented May 23, 2019

(Background: #856)

XXX_unrecognized is the internal field used to implement unknown fields. The current type is a []byte, which occupies 24B on 64-bit systems. However, the vast majority of situations do not have any unknown fields to store, so this is an increase of 24B that is mostly useless.

Consider changing this to be a pointer instead (perhaps *[]byte), to reduce the footprint to 8B.

@dsnet dsnet changed the title cmd/protoc-gen-go: use *[]byte for XXX_unrecognized cmd/protoc-gen-go: use pointer for XXX_unrecognized May 23, 2019
@tandr
Copy link

tandr commented Jul 24, 2019

@dsnet
sorry if this is a something you have already thought about, I am not familiar with new code base.

There are whole lot of XXX fluff in a current protobuf, maybe bite the bullet and offload all of them into _xxx *ProtoMeta special struct (and add "GetXXX() *..." call). Or export it, but then you can accidentally set it, not sure if this is an intention.

@dsnet
Copy link
Member Author

dsnet commented Jul 24, 2019

Variations of what you suggest is already implemented in v2. The v2 generator does not emit any XXX fields or methods.

@dsnet dsnet changed the title cmd/protoc-gen-go: use pointer for XXX_unrecognized protoc-gen-go: use pointer for unknownFields Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants