-
Notifications
You must be signed in to change notification settings - Fork 209
_WASI_EMULATED_MMAN: mmap does not return aligned memory #207
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
Comments
Fixing doesn't look easy because it hides metadata in the first N bytes of its allocation. |
Agreed. And in most cases, page-aligning wouldn't matter, because there's no |
I think that actual alignment will depend on alignof(struct map) since we do a |
Ah, good catch. |
Hi, as part of the WLR project, we found a couple of use cases where aligned memory is needed for In SQLite, lockBtree() fails when reading a DB from file in WAL mode. |
Indeed, that's a bug. We should use |
Or, oh, I missed the context here. Yes, we still need to think about padding after the header. And with wasm32's 64 KiB page sizes, that's a lot of padding. @gzurl If the goal here is to optimize at a low level for performance, calling |
@sunfishcode you are right, since this is a limited emulation of Regarding how it's used in SQLite and PHP, as you know,
Given this context, we wonder about similar cases to PHP. If we had a PS: Linking with a related issue in WASI #304. |
I think the current |
Given that wasm-libc's mmap is known is fake and non-optimal, perhaps we can see it as a stop gab for folks who don't want to take the extra time to add a non-mmap-based codepath for their code? Given that it is already emulated/fake/not recommended for production, why not just take the 64-kb hit per allocation by default? This would give us something that works out-of-the-box, but is not completely optimal (i.e. the goal the fake mmap). It would then be incumbent upon folks that care about optimization to remove their usage of our fake mmap. |
That's reasonable. And it does make wasi-libc simpler if we avoid adding a new config macro. So then yes, we should change wasi-libc to page-align. |
I really like the fact the folks have to opt into |
It does not return aligned memory (WebAssembly/wasi-libc#207) and we don't need it for anything fancy. Instead, just use posix_memalign() and free() for the GC functions.
It does not return aligned memory (WebAssembly/wasi-libc#207) and we don't need it for anything fancy. Instead, just use posix_memalign() and free() for the GC functions.
It does not return aligned memory (WebAssembly/wasi-libc#207) and we don't need it for anything fancy. Instead, just use posix_memalign() and free() for the GC functions.
It does not return aligned memory (WebAssembly/wasi-libc#207) and we don't need it for anything fancy. Instead, just use posix_memalign() and free() for the GC functions.
It does not return aligned memory (WebAssembly/wasi-libc#207) and we don't need it for anything fancy. Instead, just use posix_memalign() and free() for the GC functions.
It does not return aligned memory (WebAssembly/wasi-libc#207) and we don't need it for anything fancy. Instead, just use posix_memalign() and free() for the GC functions.
The memory returned from mmap is supposed to be page aligned.
The file offset passed in is also required to be page aligned.
The text was updated successfully, but these errors were encountered: