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

Smallen codegen #158

Merged
merged 6 commits into from
Dec 14, 2023
Merged

Smallen codegen #158

merged 6 commits into from
Dec 14, 2023

Conversation

goffrie
Copy link
Contributor

@goffrie goffrie commented Dec 7, 2023

Depends on #157.

This PR implements a series of optimizations to try to reduce the amount of generated code with the aim of speeding up compilation. Altogether this makes our slowest proto crate a bit over 10% faster to compile (~41s to ~35s).

The changes, in separate commits, are:

  • Codify the three separate cases for deserialization (packed repeated, length-delimited, non-length-delimited) into helper functions
  • Move into_known for open enums into the OpenProtoEnum trait, then use it to default-impl the other methods of that trait
  • Add special-cased helper functions for the common case of serializing (and compute_size-ing) non-optional proto3 scalar fields
  • Iterate optional fields using if let instead of for
  • Skip compute_grpc_slices_size calls/impls for fields/types where we know statically that no Lazy<> fields are present. This uses the SCC analysis.

@goffrie goffrie requested a review from cyang1 December 7, 2023 19:09
Base automatically changed from sccs to main December 14, 2023 17:10
@goffrie goffrie merged commit 5c81968 into main Dec 14, 2023
23 checks passed
@goffrie goffrie deleted the smaller-codegen-2 branch December 14, 2023 17:16
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.

1 participant