-
Notifications
You must be signed in to change notification settings - Fork 237
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
Event queue processes and filling race. #253
Conversation
It make be that it would be better to create a new sized slice to avoid the subsequent allocations during growth. |
@tcolgate Agreed. The expectation in the existing code is that the slice is going to grow to the size needed, and once it does, future memory allocations can be avoided. Making a copy before sending it over the channel seems like the way to go. |
That makes sense, a single reasonably-sized allocation is better than many smaller ones ending in the same size. We're trading a tiny bit of memory usage for low-traffic use cases but I think that is acceptable. |
I see two options:
I vote for option 2 (for a busy server, I guess the degenerate to the same thing) |
I think that's the best way. |
We send the slice off to be process, but potentially start overwriting the previous content straight away. Just start again with a fresh slice. Fixes prometheus#247 Signed-off-by: Tristan Colgate <tristan@qubit.com>
@matthiasr I changed my mind, or rather, maybe we do both. This allocates the initial slice, and then just keeps copying the cap after that. This will cause something like 160KB of extra allocation on startup by default, I don't think people will notice. |
Thank you! |
We send the slice off to be process, but potentially start overwriting
the previous content straight away. Just start again with a fresh slice.
Fixes #247