-
Notifications
You must be signed in to change notification settings - Fork 48
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
perf: speed up adding fields, reduce memalloc if field name is already prefixed with "app." #406
Conversation
There is a remarkable amount of memory allocation occurring under load to perform the field name "app." prefixing by the Beeline with "app.". This change skips the memory allocations needed for string concat and usage if the "app." prefix is already present on the field name provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good call, and provides a nice on-ramp to adding the app prefix explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the right way to go. The work done in #402 by introducing a cache introduced too much lock contention. This will allow users of the beeline to improve perf. by doing the app.
prefix themselves.
The query is not blocking and I don't think it'll have a material impact.
We have concluded that calling functions as parameters to functions is not as easy to read as local variable assignment and using the variable as the parameter. Benchmarking indicates that there is no difference in allocations between assigning a local variable in AddField() and having a function return a value that is immediately used as a parameter still within the scope of AddField().
Co-authored-by: JamieDanielson <[email protected]>
Which problem is this PR solving?
There is a remarkable amount of memory allocation occurring under load to perform the "app." prefixing of field names by the Beeline.
Short description of the changes
This change skips the memory allocations needed for string concat and usage if the "app." prefix is already present on the field name provided.
Benchmarks
Existing behavior is no slower or memory hungry, but for every field name provided by the Beeline user that starts with "app.", that is one less memory allocation of the size of the field name string.