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

ProtobufSerializer minimize getSerializedSize() usage #2694

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

Scottmitch
Copy link
Member

Motivation:
ProtobufSerializer uses MessageLite.getSerializedSize() on each serialization operation. This method may require a deep traversal of all internal objects and require intermediate allocations (e.g. for maps) to compute the actual size.

Modifications:

  • Use CodedOutputStream.getTotalBytesWritten() and CodedInputStream.getTotalBytesRead() to determine how many bytes were generated/consumed during serialization.

Motivation:
ProtobufSerializer uses `MessageLite.getSerializedSize()` on each
serialization operation. This method may require a deep traversal
of all internal objects and require intermediate allocations
(e.g. for maps) to compute the actual size.

Modifications:
- Use `CodedOutputStream.getTotalBytesWritten()` and
`CodedInputStream.getTotalBytesRead()` to determine how many bytes
were generated/consumed during serialization.
@Scottmitch Scottmitch merged commit c9b1fc5 into apple:main Sep 18, 2023
@Scottmitch Scottmitch deleted the grpc_serializer_sizes branch September 18, 2023 15:56
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.

2 participants