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

Canister limit #3754

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

Canister limit #3754

wants to merge 2 commits into from

Conversation

mraszyk
Copy link
Contributor

@mraszyk mraszyk commented Nov 15, 2024

Add function to query current resource limit for the canister.

@mraszyk mraszyk requested a review from a team as a code owner November 15, 2024 11:06
Copy link

github-actions bot commented Nov 15, 2024

🤖 Here's your preview: https://uy5c7-yiaaa-aaaam-abxxa-cai.icp0.io

@mraszyk mraszyk marked this pull request as draft November 15, 2024 11:52
@mraszyk mraszyk added the interface-spec Changes to the IC Interface Specification label Nov 18, 2024

- 1 : The [instruction limit per update message](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit).

- 2 : The [instruction limit per upgrade message](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit).
Copy link
Member

Choose a reason for hiding this comment

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

We should explain in more detail what we mean here – sum of pre_upgrade and post_upgrade?


- 3 : The [maximum number of stable memory Wasm pages that can be accessed per update message](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit).

- 4 : The [maximum number of stable memory Wasm pages that can be accessed per upgrade message](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit).
Copy link
Member

Choose a reason for hiding this comment

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

See above, "upgrade message" is not a term we use elsewhere.

@@ -1944,6 +1945,26 @@ The argument `type` decides which performance counter to return:

In the future, the IC might expose more performance counters.

### Canister limit {#system-api-canister-limit}

The canister can query one of the "canister limits", which denotes a resource limit of the canister imposed by the current configuration of the IC and/or canister. This allows runtime logic, such garbage collector or persistence mechanism, to adapt to the system limits without recompilation and redeployment.
Copy link
Member

Choose a reason for hiding this comment

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

Do we return the limit (meaning: the constant) or the remaining budget in the current execution?


`ic0.canister_limit : (limit_type : i32) -> i64`

The argument `limit_type` determines which resource limit to return:
Copy link
Member

@Dfinity-Bjoern Dfinity-Bjoern Nov 19, 2024

Choose a reason for hiding this comment

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

Should we add a limit for the remaining memory (heap or stable) pages that could still be allocated by the canister?


The argument `limit_type` determines which resource limit to return:

- 0 : The [soft Wasm heap memory limit](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit), or the IC-defined [hard Wasm memory limit](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/resource-limits#resource-constraints-and-limits), whatever is smaller. The limit is specific to the canister, depending on the canister configuration (for the soft limit) and on whether it uses 32-bit or 64-bit Wasm memory.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this also consider the subnet available memory?

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