-
Notifications
You must be signed in to change notification settings - Fork 259
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
Dynamically detect support for Wasmtime's pooling allocator #2508
Dynamically detect support for Wasmtime's pooling allocator #2508
Conversation
This commit is intended to address fermyon#2119 and mirror bytecodealliance/wasmtime#8610. The base problem is that some systems are configured with smaller amounts of virtual memory than other systems, for example some aarch64 and riscv64 systems are shown to have only 39 bits of virtual address space rather than the 48 by default on x86_64. This means that the pooling allocator can't be initialized on these platforms since it needs more virtual memory than that. This changes Spin to dynamically choosing whether to use the pooling allocator. It's still used by default in Wasmtime but a dynamic probe is performed to determine whether it's going to work first. While here I also added an env var to control this behavior for an escape hatch if that's needed in the future too. Closes fermyon#2119 Signed-off-by: Alex Crichton <alex@alexcrichton.com>
a2cdd07
to
a06b6b3
Compare
Also fixes #2343 |
crates/core/src/lib.rs
Outdated
match std::env::var("SPIN_WASMTIME_POOLING") { | ||
Ok(s) if s == "1" => return true, | ||
Ok(s) if s == "0" => return false, | ||
_ => {} |
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 think we should respect SPIN_WASMTIME_POOLING
if it's set no matter what. If it's set to "0" or "false", we can turn it off, and otherwise enable it.
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.
Sure yeah, I opted to panic for non 0/1 values to avoid making this too too sprawling (as it's probably not going to be used that much anyway)
Signed-off-by: Alex Crichton <alex@alexcrichton.com>
This commit is intended to address #2119 and mirror bytecodealliance/wasmtime#8610. The base problem is that some systems are configured with smaller amounts of virtual memory than other systems, for example some aarch64 and riscv64 systems are shown to have only 39 bits of virtual address space rather than the 48 by default on x86_64. This means that the pooling allocator can't be initialized on these platforms since it needs more virtual memory than that.
This changes Spin to dynamically choosing whether to use the pooling allocator. It's still used by default in Wasmtime but a dynamic probe is performed to determine whether it's going to work first. While here I also added an env var to control this behavior for an escape hatch if that's needed in the future too.
Closes #2119
Closes #2343