-
Notifications
You must be signed in to change notification settings - Fork 294
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
mmap impl for MemoryInstance #45
Comments
Lazily zero-filling can be done with |
Yeah, |
What we can do is make a huge mmap and then |
It looks like Rust has a seperate mechanism for allocating zeroed memory, which would imply that it uses |
Just to come back to this, you can definitely use std::mem;
unsafe fn calloc(size: usize, count: usize) -> *mut u8 {
let mut allocation: Vec<u8> = vec![0; size * count];
let ptr = allocation.as_mut_ptr();
assert!(ptr as usize % mem::size_of::<usize>() == 0);
mem::forget(allocation);
ptr
} |
Notes from working on #190
|
#274 implements exactly this on 64-bit platforms. Therefore this issue can be closed as soon as it has been merged. |
Closed since #274 has been merged. |
When the heap grows from, say, 1GB to 3GB, in naive vector implementation of MemoryInstance we need to reallocate vector, copy 1GB worth of data into the new vector and then fill with zeroes newly allocated 2GB worth of data.
On 64-bit machines (and maybe in some cases on 32-bit ones) we might allocate virtual memory up to memory instance's limit, and then just move the heap_end pointer upon call to
grow
, thus avoiding memory copying. Maybe it is possible to do zero-filling in a lazy way, i.e upon the first access to the page, however, i'm not sure how to do this in robust and portable manner.The text was updated successfully, but these errors were encountered: