Skip to content

Conversation

@yamt
Copy link
Contributor

@yamt yamt commented Dec 25, 2023

Summary

using 0 by default seems a bit too aggressive to me.

1024 here is what would have been used before this kconfig knob was introduced by #1259. It also matches some expectations in the recent wamrc. https://github.com/bytecodealliance/wasm-micro-runtime/blob/40b430fd240ad45f5c7a7dd0239fa2425e7c294e/core/iwasm/compilation/aot_emit_aot_file.c#L2672-L2678

Impact

Testing

@yamt
Copy link
Contributor Author

yamt commented Dec 25, 2023

@no1wudi how do you think?

@no1wudi
Copy link
Contributor

no1wudi commented Dec 25, 2023

@no1wudi how do you think?

LGTM, and maybe we should notify user that using thread, since default thread on nuttx is 2048 for many platforms.

config INTERPRETERS_WAMR_STACK_GUARD_SIZE
int "Custom stack guard size"
default 0
default 1024
Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it good to resolve 1KB for stack guard by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by "resolve" in this context?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo I mean reserve

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1KB might be a bit too large for typical nuttx targets.
but it's definitely safer than 0.
also, 1KB is what wamr uses by default for other platforms.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that the stack size consumed by wamr function is fixed, why wasm engine can't catch the stack overflow before jump to the new function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because your assumption is wrong?
at least in the current wamr aot implementation, a caller doesn't have precise knowledge about how much stack the callee consumes. the callees need to check the overflow by itself and the check itself might consume stack. (thus the small amount of stack is reserved here.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But 1KB isn't a small amount of stack.

using 0 by default seems a bit too aggressive to me.

1024 here is what would have been used before this kconfig knob
was introduced by apache#1259.
It also matches some expectations in the recent wamrc.
https://github.com/bytecodealliance/wasm-micro-runtime/blob/40b430fd240ad45f5c7a7dd0239fa2425e7c294e/core/iwasm/compilation/aot_emit_aot_file.c#L2672-L2678
@yamt yamt force-pushed the wamr-stack-guard branch from 415d714 to 4d2eea3 Compare January 19, 2024 05:50
@yamt
Copy link
Contributor Author

yamt commented Jan 19, 2024

@no1wudi how do you think?

LGTM, and maybe we should notify user that using thread, since default thread on nuttx is 2048 for many platforms.

i added some description in the help text.

@jerpelea jerpelea merged commit 70108ae into apache:master Jan 19, 2024
the majority of other platforms, including Linux. It also matches
the expections in the WAMR AoT compiler.
On the other hand, it might be a bit larger than what's strictly
necessary, especially for typical NuttX targets.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, why not give a small value match the nuttx normal case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just because it's difficult to fine tune this kind of things.

config INTERPRETERS_WAMR_STACK_GUARD_SIZE
int "Custom stack guard size"
default 0
default 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But 1KB isn't a small amount of stack.

wenyongh pushed a commit to bytecodealliance/wasm-micro-runtime that referenced this pull request Jan 23, 2024
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants