-
Notifications
You must be signed in to change notification settings - Fork 307
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
chunk_mut should not allocate #518
Comments
This is intended behavior. As for the size of the allocation, the new capacity will actually be something like |
huh. Coming from other languages I had assumed a "zero-copy" network buffer library would also imply "zero non-explicit allocations" as those are a few orders of magnitude more expensive. Or at least have it as an option. Working on embedded / latency-sensitive systems was a bit of a shock to find allocations happening "under the hood". It's also doesn't seem to be documented any place that this happens. Should I be concerned about other places doing allocations that aren't generally known? Am I going to discover them via valgrind? |
All of the uses of It is documented on the doc page for
Of course, we can add it to the |
To elaborate a bit more: The |
No, because that's the common way they work. It's also very well documented. Same as calling Would you be surprised if this relocated? let mut buf: Vec<u8> = Vec::with_capacity(16);
let l = buf.len();
let s = &mut buf[l..]; Yes. That would be very surprising. Edit : I think the way it is is fine, just surprising, I'm not trying to advocate for something else. However, every network/buffering library I've ever used in every language has a "no grow" option (or it's the only option). Where |
I was surprised to discover
chunk_mut
doing an allocation if the buffer is full. I would think it would return a 0 length slice.Is this intended behaviour, or an oversight? If intended why only allocate 64 ? why not
os.page_size
, or 64K. It seems kinda arbitrary.The text was updated successfully, but these errors were encountered: