Skip to content
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

Merged

Conversation

alexcrichton
Copy link
Contributor

@alexcrichton alexcrichton commented May 14, 2024

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

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>
@alexcrichton alexcrichton force-pushed the probe-for-the-pooling-allocator branch from a2cdd07 to a06b6b3 Compare May 14, 2024 15:53
@lann
Copy link
Collaborator

lann commented May 14, 2024

Also fixes #2343

@alexcrichton alexcrichton enabled auto-merge May 14, 2024 15:58
match std::env::var("SPIN_WASMTIME_POOLING") {
Ok(s) if s == "1" => return true,
Ok(s) if s == "0" => return false,
_ => {}
Copy link
Collaborator

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.

Copy link
Contributor Author

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)

crates/core/src/lib.rs Outdated Show resolved Hide resolved
crates/core/src/lib.rs Show resolved Hide resolved
@alexcrichton alexcrichton disabled auto-merge May 14, 2024 16:10
Signed-off-by: Alex Crichton <alex@alexcrichton.com>
@alexcrichton alexcrichton merged commit 5d09e10 into fermyon:main May 14, 2024
17 checks passed
@alexcrichton alexcrichton deleted the probe-for-the-pooling-allocator branch May 14, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants