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

feat: on low wasm memory hook #3761

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

mraszyk
Copy link
Contributor

@mraszyk mraszyk commented Nov 15, 2024

This proposal is based on this forum post and has already been approved by motion proposal 106146.

Canister developers have to actively monitor their canisters to know if they are low on wasm memory. If detected too late, a canister can be completely stuck and forever un-upgradable.

To address this, we introduce a hook called on_low_wasm_memory. When defined, it is triggered whenever the canister's memory usage exceeds some developer-defined threshold.

@mraszyk
Copy link
Contributor Author

mraszyk commented Nov 15, 2024

If the canister gets frozen immediately after the function is scheduled for execution, the function will run once the canister's unfrozen if the canister's wasm memory remains above the threshold t.

This property is not established by the implementation.

@mraszyk
Copy link
Contributor Author

mraszyk commented Nov 15, 2024

The implementation only considers stable memory and ignores, e.g., the chunk store and snapshot size, when deriving the wasm memory capacity.

@mraszyk
Copy link
Contributor Author

mraszyk commented Nov 15, 2024

The hook should not run after an upgrade/reinstall/uninstall/install if the condition is not satisfied after the upgrade (although the condition was satisfied before the upgrade and the hook did not execute yet).

Copy link

github-actions bot commented Nov 15, 2024

🤖 Here's your preview: https://xaml7-fiaaa-aaaam-abdka-cai.icp0.io

@mraszyk mraszyk added the interface-spec Changes to the IC Interface Specification label Nov 18, 2024
@dragoljub-duric
Copy link

Regarding the point:
"The hook should not run after an upgrade/reinstall/uninstall/install if the condition is not satisfied after the upgrade (although the condition was satisfied before the upgrade and the hook did not execute yet)."
Because the hook condition is checked whenever the canister tries to grow wasm memory, can it ever happen that the canister does not try to grow wasm memory when running upgrade/reinstall/uninstall/install?

@mraszyk
Copy link
Contributor Author

mraszyk commented Nov 26, 2024

Because the hook condition is checked whenever the canister tries to grow wasm memory, can it ever happen that the canister does not try to grow wasm memory when running upgrade/reinstall/uninstall/install?

Yes, e.g., if the canister does not have any pre- and post-upgrade hooks (in which case there's no wasm execution during canister installation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interface-spec Changes to the IC Interface Specification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants