-
Notifications
You must be signed in to change notification settings - Fork 2
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
follow up on ways to reduce allocation on multi_get #45
base: main
Are you sure you want to change the base?
Conversation
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.
Only a couple comments, but nothing that should block this PR as-is.
Note: this is the optimized get multi only use for single server with raw mode... we should run tests in deployed systems (staging) before merging |
@@ -249,7 +250,7 @@ def next_line_to_tokens | |||
|
|||
def read_data(data_size) | |||
resp_data = @io_source.read(data_size) | |||
@io_source.read(TERMINATOR.bytesize) | |||
@io_source.read_to_outstring(TERMINATOR.bytesize, @terminator_buffer) |
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 removes an additional allocation for all the non multi calls
Ok, this is a bit silly, but after our conversation I was curious how much we could reduce allocations in the get multi tight loop... This does reduce allocations which is nice, but the overall benchmark doesn't show much of a difference... Still kind of fun to poke around at, and it might be nice to add a check to CI that ensures we keep pushing allocations down for our commands.
allocations before:
1944
allocations after:
1659
benchmark before:
benchmark after:
paired with Aaron and was able to cut allocations in half... while it still doesn't show up as much in a micro benchmark this should add up across all cache calls across all web requests. The new method is a bit harder to understand, but feels worth it for such a frequently used tight loop.