Skip to content

Implement grow_zeroed efficiently where possible #100

Open
@andylizi

Description

@andylizi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions