-
Notifications
You must be signed in to change notification settings - Fork 986
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
runtime: Add env var for maximum stack size #2719
Conversation
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.
This should be documented in https://github.com/graphprotocol/graph-node/blob/master/docs/environment-variables.md.
@leoyvens should I put it in the running mapping handlers section, or create another one about the |
8778668
to
37e27e2
Compare
runtime/wasm/src/mapping.rs
Outdated
@@ -140,6 +149,8 @@ impl ValidModule { | |||
config.interruptable(true); // For timeouts. | |||
config.cranelift_nan_canonicalization(true); // For NaN determinism. | |||
config.cranelift_opt_level(wasmtime::OptLevel::None); | |||
config.max_wasm_stack(*MAX_STACK_SIZE)?; |
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.
Do you think it makes a difference to unwrap
right here? The only error this can return is this one, which is when the size
parameter is 0
.
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.
This could be unwrapped.
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.
Unwrapped (with comment 🙂 )!
runtime/wasm/src/mapping.rs
Outdated
.ok() | ||
.and_then(|max_stack_size| max_stack_size.parse().ok()) | ||
// 512KiB | ||
.unwrap_or((ONE_MIB as f32 * 0.5) as usize); |
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.
What's wrong with division by 2?
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.
Nothing wrong, for some reason I felt like 0.5
was easier to associate with 512KiB
.
Also I think it's easier to change if we want something like 800KiB
.
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.
Not that it matters here, but integer arithmetic is much easier to reason about than float arithmetic, if we need to change this to something else we can introduce new constants.
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.
Fixed!
37e27e2
to
fea87c0
Compare
fea87c0
to
7319d7f
Compare
Just an environment variable to set the maximum stack size for the WASM runtime.
If not set, the default is 512KiB, half of what it was before (default from
wasmtime
crate was 1MiB).