-
Notifications
You must be signed in to change notification settings - Fork 96
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
Go: Allocate less in indexed message chunk loading #950
Conversation
dad9b02
to
8644365
Compare
simple timings main
patch
40% faster |
8644365
to
7e74508
Compare
Prior to this commit, when reading a chunk into memory we would read it (internally, in io.ReadAll) into a resizing buffer and need to resize it several times up to final size. Since we know the final size in advance we can preallocate and save those allocations/copies.
lz4 numbers main
patch
|
it seems like there would be further savings if we could reuse the chunk buffers, but I think this is too complicated by the heap. I also noticed the Next() method still takes a buffer which is now unused (I think originally that was passed to the lexer's Next method to conserve allocations) but I think resurrecting it is complicated now. Maybe we can sunset it, or maybe it actually is used for the unindexed iterator (need to check). |
last commit shaves a bit more off
|
with final commit, I got a
which is close to 50% better than the first observation |
there is still some preexisting issue with very large inputs, where reading becomes sluggish after a while. I need to debug it further to understand what is happening. Won't merge this til I understand better. |
ok I think ^^ is just my terminal emulator, I verified with pv there's no actual slowdown and if I use xterm it appears to read at a consistent speed too. Merging. |
Prior to this commit, when reading a chunk into memory we would read it (internally, in io.ReadAll) into a resizing buffer and need to resize it several times up to final size. Since we know the final size in advance we can preallocate and save those allocations/copies.