Skip to content
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

Implement grow_zeroed efficiently where possible #100

Open
andylizi opened this issue Jun 14, 2022 · 0 comments
Open

Implement grow_zeroed efficiently where possible #100

andylizi opened this issue Jun 14, 2022 · 0 comments

Comments

@andylizi
Copy link

This was suggested a long time ago in #14, but although efficiency was mentioned as one of the motivations, the implementation just calls memset without making use of any potentially faster platform APIs.

I think these should be added since they can be efficiently implemented with the mremap system call on Linux. mremap allows you to move/grow/shrink a memory mapping, and any new pages added for growth are guaranteed to be zeroed.

Unfortunately for unix platforms, we're forwarding to libc whose realloc() doesn't support zeroing. But Windows HeapReAlloc does have HEAP_ZERO_MEMORY, and we're already using that for alloc_zeroed. So why not realloc_zeroed?

Here's my proof-of-concept: https://github.com/andylizi/rust/commits/realloc-zeroed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant