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

Treewalker: Improve performance by avoiding memory allocations #309

Merged
merged 3 commits into from
Jan 29, 2024

Conversation

lfittl
Copy link
Member

@lfittl lfittl commented Jan 27, 2024

Previously the treewalker would unnecessary call "to_h" on each Protobuf message in the parsetree, in order to get the field names to walk. This caused unnecessary copies of the message, increasing memory usage and slowing down the tree walk. Instead, use the Protobuf descriptor and its field descriptors to walk the message.

Additionally this also optimizes the case where a block with 1 argument is used for the tree walk, since we don't need to handle the location, avoiding unnecessary copies of the field name string.

Together these changes result in about a 5x speed up in some use cases.

@lfittl lfittl force-pushed the speed-up-treewalker branch 2 times, most recently from 0014cae to cb8292b Compare January 27, 2024 06:31
Previously the treewalker would unnecessary call "to_h" on each Protobuf
message in the parsetree, in order to get the field names to walk. This
caused unnecessary copies of the message, increasing memory usage and
slowing down the tree walk. Instead, use the Protobuf descriptor and its
field descriptors to walk the message.

Additionally this also optimizes the case where a block with 1 argument
is used for the tree walk, since we don't need to handle the location,
avoiding unnecessary copies of the field name string.

Together these changes result in about a 5x speed up in some use cases.
@lfittl lfittl requested a review from a team January 27, 2024 07:01
lfittl and others added 2 commits January 27, 2024 09:14
Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
@lfittl lfittl merged commit f23f1df into main Jan 29, 2024
10 checks passed
@lfittl lfittl deleted the speed-up-treewalker branch January 29, 2024 19: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.

None yet

4 participants