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

Use bit-field int values in buildPartial to skip work on unset groups of fields. #10960

Merged
merged 1 commit into from
Nov 14, 2022

Conversation

googleberg
Copy link
Member

@googleberg googleberg commented Nov 10, 2022

Changes to make this improvement:

  1. All non-repeated builder fields (including maps) now have a presence bit regardless of syntax.

  2. The buildPartial method is split into one method per 32-field block (aligned with bit-mask ints)

  3. If a presence bit-mask int is set to 0, no fields are present, so we can skip the logic for all of those fields in the buildPartial step.

For messages with a lot of fields (> 100) that are sparsely populated this can result in a significant improvement. Not only does it potentially skip a lot of field copying logic, but also breaks the buildPartial method into chunks that should be more easily digested by the JIT compiler as discussed in this issue: #10247.

PiperOrigin-RevId: 485952448

… of fields.

Changes to make this improvement:
1) All non-repeated builder fields (including maps) now have a presence bit regardless of syntax.
2) The buildPartial method is split into one method per 32-field block (aligned with bit-mask ints)
3) If a presence bit-mask int is set to 0, no fields are present, so we can skip the logic for all of those fields in the buildPartial step.

For messages with a lot of fields (> 100) that are sparsely populated this can result in a significant improvement. Not only does it potentially skip a lot of field copying logic, but also breaks the buildPartial method into chunks that should be more easily digested by the JIT compiler as discussed in this issue: #10247.

PiperOrigin-RevId: 485952448
@googleberg googleberg merged commit 4f393bd into 21.x Nov 14, 2022
@jorgbrown jorgbrown mentioned this pull request Nov 29, 2022
gengliangwang added a commit to apache/spark that referenced this pull request Dec 13, 2022
### What changes were proposed in this pull request?

Upgrade Protobuf version to 3.21.11

### Why are the changes needed?

There are some bug fixes in the latest release https://github.com/protocolbuffers/protobuf/releases:
* Use bit-field int values in buildPartial to skip work on unset groups of fields. (protocolbuffers/protobuf#10960)
* Mark nested builder as clean after clear is called (protocolbuffers/protobuf#10984)

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

GA tests

Closes #39042 from gengliangwang/upgradeProtobuf.

Authored-by: Gengliang Wang <gengliang@apache.org>
Signed-off-by: Gengliang Wang <gengliang@apache.org>
beliefer pushed a commit to beliefer/spark that referenced this pull request Dec 18, 2022
### What changes were proposed in this pull request?

Upgrade Protobuf version to 3.21.11

### Why are the changes needed?

There are some bug fixes in the latest release https://github.com/protocolbuffers/protobuf/releases:
* Use bit-field int values in buildPartial to skip work on unset groups of fields. (protocolbuffers/protobuf#10960)
* Mark nested builder as clean after clear is called (protocolbuffers/protobuf#10984)

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

GA tests

Closes apache#39042 from gengliangwang/upgradeProtobuf.

Authored-by: Gengliang Wang <gengliang@apache.org>
Signed-off-by: Gengliang Wang <gengliang@apache.org>
@zhangskz zhangskz deleted the gberg-ads-performance branch February 15, 2023 19:00
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.

4 participants