Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
memfd/madvise-based CoW pooling allocator #3697
memfd/madvise-based CoW pooling allocator #3697
Changes from 2 commits
b73ac83
3702e81
570dee6
982df2f
ccfa245
0ff8f6a
01e6bb8
84a8368
94410a8
0ec45d3
d7b04f5
9880eba
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given where this PR now is and the trajectory of this feature, I think this is good to have as an optional dependency but I think it should be enabled by default and probably just called
memfd
(enabled-by-default probably from thewasmtime
crate, not here). Especially with this making such a drastric difference for the on-demand allocator it seems like usingmemfd
is a no-brainer.To make this tweak as well as improve the portability here (right now if you enable
memfd
on Windows it'd probably just fail to compile) I think a few small changes are all that's needed. To be clear though this is icing on the cake and it's totally fine to do this as a follow-up, but I think the steps would be:memfd-allocator
memfd
feature to thewasmtime
crate that forwards towasmtime-runtime/memfd
memfd
to the default feature set of thewasmtime
cratecrates/runtime/build.rs
that detects that the target's os is Linux (by looking atCARGO_CFG_TARGET_OS
) and that thememfd
feature is active (by looking atCARGO_FEATURE_MEMFD
), and if both are present then printingprintln!("cargo:rustc-cfg=memfd")
cfg(feature = "memfd-allocator")
in the crate tocfg(memfd)
With that I think we'll have on-by-default memfd for Linux-only, with the opt-in ability to turn it off. Again though it's fine to defer this to a future PR.
As I type all this out though I also would question maybe we don't even need a feature for this. I suppose one thing that could come up is that if you have a million modules in a process that's a million file descriptors which can blow kernel limits, but other than that I'm not sure why anyone would explicitly want to disable memfd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone ahead and done all of this; the default build now will use memfd, validated by building the
wasmtime
binary and strace'ing an execution. Waiting for CI to see if movingmemfd
out of the target-only deps into the main deps will work on non-Linux, but I am hoping it will (the crate's got a toplevel#![cfg(target_os ...)]
that should make it a no-op on other platforms...?).