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

Fix performance problems when compiling generated code with Kotlin 1.4 #101

Merged
merged 2 commits into from
Oct 23, 2020

Conversation

garyp
Copy link
Collaborator

@garyp garyp commented Oct 23, 2020

When a protobuf message definition contains a lot of fields/oneofs, the generated Kotlin code cannot be compiled by a Kotlin 1.4 compiler. The compiler runs out of memory when compiling the long list of FieldDescriptors that gets passed to the MessageDescriptor. This change implements a workaround that avoids the Kotlin compiler bug by initializing the list of FieldDescriptors outside of the MessageDescriptor constructor.

Also add a test proto file to catch regressions with large protobuf messages.

The first commit contains all of the interesting changes. The second commit is just the result of running the gradle command to regenerate all proto definitions.

Fixes #94

@garyp garyp changed the title bug/GH 94 kotlin 1.4 perf regression Fix performance problems when compiling generated code with Kotlin 1.4 Oct 23, 2020
garyp added 2 commits October 22, 2020 21:14
When a protobuf message definition contains a lot of fields/oneofs, the
generated Kotlin code cannot be compiled by a Kotlin 1.4 compiler. The
compiler runs out of memory when compiling the long list of
`FieldDescriptor`s that gets passed to the `MessageDescriptor`. This
change implements a workaround that avoids the Kotlin compiler bug by
initializing the list of `FieldDescriptor`s outside of the
`MessageDescriptor` constructor.

Also add a test proto file to catch regressions with large protobuf
messages.

Fixes #94
@garyp garyp force-pushed the bug/GH-94-kotlin-1.4-perf-regression branch from 8c61e26 to cb41f42 Compare October 23, 2020 04:14
@garyp garyp marked this pull request as ready for review October 23, 2020 04:35
@garyp garyp mentioned this pull request Oct 23, 2020
Copy link
Contributor

@seanadkinson seanadkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@dustinbrown dustinbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, i'm working with validation, i'm adding messages with lots of fields. Great timing!

@garyp garyp merged commit 54377c0 into master Oct 23, 2020
@garyp garyp deleted the bug/GH-94-kotlin-1.4-perf-regression branch October 23, 2020 18:22
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.

Compilation Performance
3 participants