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

[FINAL] feat: on low wasm memory hook #3761

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

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).

@Dfinity-Bjoern Dfinity-Bjoern marked this pull request as ready for review December 10, 2024 14:32
@Dfinity-Bjoern Dfinity-Bjoern requested a review from a team as a code owner December 10, 2024 14:32
@Dfinity-Bjoern Dfinity-Bjoern changed the title feat: on low wasm memory hook [FINAL] feat: on low wasm memory hook Dec 10, 2024
github-merge-queue bot pushed a commit to dfinity/ic that referenced this pull request Dec 18, 2024
…#2864)

To support `on_low_wasm_memory` hook we are adding
`wasm_memory_threshold` to `NNS` so it allows users to update its value
using `NNS` proposal. We are as well adding `wasm_memory_threshold` to
canister settings to canisters in `IC` repo.

The `wasm_memory_threshold` will be added to the interface specification
in dfinity/portal#3761

---------

Co-authored-by: Andre Popovitch <[email protected]>
Co-authored-by: Arshavir Ter-Gabrielyan <[email protected]>
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