Repository navigation
feat: Export million_round_instructions_total in subnet_metrics - #11587
Merged
Merged
Conversation
This commit adds an addition field returned with the subnet_metrics management canister endpoint. It tracks the existing prometheus metric execution_round_instructions, except that it does not get reset on replica start. One user of the existing metric and the new value are the public dashboards, with the off-chain dashboard currently relying on the prometheus metric. The new value starts at 0 with the introduction of this commit. Like the metric, the new field counts the executed wasm instructions, plus instruction overheads the scheduler uses (e.g. there is a base overhead per message). While the instructions are tracked exactly internally, they are only exported in millions of instructions. As a drive-by, this commit also fixes an issue where the metric/new total was not correctly tracked in the edge case of heap delta rate limiting kicking in.
Contributor
Author
|
Intended follow-up once this is rolled out: #11586 |
|
✅ No security or compliance issues detected. Reviewed everything up to c6df79f. Security OverviewDetected Code Changes
|
mraszyk
reviewed
Sep 16, 2026
mraszyk
reviewed
Sep 16, 2026
mraszyk
reviewed
Sep 16, 2026
mraszyk
reviewed
Sep 16, 2026
mraszyk
approved these changes
Sep 16, 2026
mraszyk
reviewed
Sep 16, 2026
mraszyk
added a commit
to dfinity/developer-docs
that referenced
this pull request
Sep 17, 2026
Documents dfinity/ic#11587, which adds a sixth field to the endpoint this branch specifies. It reports the total instructions the subnet accounted for across the execution phases of all rounds, in units of one million and rounded up, and unlike the four aggregates it has no path under `/subnet/<subnet_id>/metrics` in the certified state tree. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
mraszyk
added a commit
to dfinity/developer-docs
that referenced
this pull request
Oct 7, 2026
## Summary Specifies the EXPERIMENTAL management canister endpoint `subnet_metrics`, which returns subnet-wide metrics to canisters: the subnet block height, the four aggregates the certified state tree already exposes at `/subnet/<subnet_id>/metrics`, and the total number of instructions the subnet accounted for when executing its blocks. The block height is new; the four aggregates exist in the state tree but are unreachable from canister code, since no System API or management canister method exposes state tree paths. That is why they are bundled rather than only the block height and `consumed_cycles_total` originally requested. Covers two replica PRs: - dfinity/ic#11032 - the endpoint and its first five fields. - dfinity/ic#11587 - the sixth field `million_round_instructions_total`. ## Changes - `ic-interface-spec/management-canister.md`: new section for `subnet_metrics` with the full field semantics. - `ic-interface-spec/abstract-behavior.md`: new transition for `subnet_metrics`; the metric values are implementation-specific and attached cycles are refunded. - `ic-interface-spec/index.md`: new definitions of *cost schedules* (normal and free; a free schedule waives resource charges only, such as instruction execution, memory usage, and HTTPS outcalls, while cycles burned via `ic0.cycles_burn128`, deleted canisters' remaining cycle balances, and the cycles of dropped messages or refunds are still lost) and *nominal cycles* (the normal-schedule amount for resource charges, and the amount lost for cycles that are lost under either schedule), and corrected descriptions of the four aggregates under `/subnet/<subnet_id>/metrics` (current values vs. counters, the 10-block refresh of `canister_state_bytes`, the full composition of `consumed_cycles_total`, as a list of its four summands), so the state tree and the method describe the same quantities. - `ic-interface-spec/changelog.md`: version 0.69.0 entry covering the new endpoint, the new definitions, and the clarified state tree metrics (still the next version after merging the latest `main`, whose newest entry is 0.68.0). - `references/management-canister.md`: condensed reference entry linking to the spec. - `public/references/ic.did`: new types and method, with field comments. ## Interface ```candid type subnet_metrics_args = record { subnet_id : principal }; type subnet_metrics_result = record { block_height : nat; num_canisters : nat; canister_state_bytes : nat; consumed_cycles_total : nat; update_transactions_total : nat; million_round_instructions_total : nat; }; ``` Callable by canisters only (not via ingress), and `subnet_id` may name any subnet, not only the caller's. ## Field semantics - Only `block_height` describes the block in whose execution the call is processed. The other five are aggregates refreshed at block boundaries, so they describe an earlier block; they are not refreshed at the same rate, so they need not be mutually consistent. - `num_canisters` and `canister_state_bytes` are current values, not counters. `canister_state_bytes` refreshes only every 10 blocks, at heights that are multiples of 10. It reads 0 before the first refresh. - `consumed_cycles_total` is measured in *nominal cycles*: resource charges are recorded at normal cost-schedule rates even on a subnet with a free cost schedule, where no cycles are deducted from canister balances. It sums the historical consumption of the canisters currently on the subnet, the historical consumption of the canisters deleted on the subnet plus their remaining cycle balances at deletion, the cycles charged at the subnet level for HTTPS outcalls, threshold signature requests, and vetKD requests, and the cycles lost when messages or refunds are dropped (for example, because their recipient no longer exists). Refunds of prepaid charges reduce the total. Subnet splitting redistributes canisters' histories, so the total can decrease and can include consumption from before the receiving subnet was created. It is not a count of cycles actually burned on this subnet. - `update_transactions_total` counts messages executed in replicated mode. It and `million_round_instructions_total` are monotonically non-decreasing counters covering the subnet's lifetime, or the period since each metric was introduced for subnets that predate it. - `million_round_instructions_total` is reported in units of one million and rounded up: a value of `42` represents 41,000,001 through 42,000,000 instructions. It counts the instructions accounted for when executing the subnet's blocks. Besides the executed Wasm instructions, it covers the fixed per-execution and per-canister overheads charged by the scheduler and the charges for work performed outside of Wasm execution (compilation, chunk assembly, snapshots), so it is not a Wasm instruction meter. - `block_height` and `million_round_instructions_total` are the two fields with no path under `/subnet/<subnet_id>/metrics`, so they are available only through this method and cannot be verified against a certificate. ## Follow-ups outside this repo - `ic-cdk` and Motoko management canister bindings. - dfinity/ic: the `million_round_instructions_total` comment in `rs/types/management_canister_types/tests/ic.did` says "Unlike the four fields above", but five fields precede it and `block_height` also has no state tree path. --------- Co-authored-by: Bjoern Tackmann <[email protected]> Co-authored-by: mraszyk <[email protected]> Co-authored-by: Martin Raszyk <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds an addition field returned with the subnet_metrics management canister endpoint. It tracks the existing prometheus metric execution_round_instructions, except that it does not get reset on replica start.
One user of the existing metric and the new value are the public dashboards, with the off-chain dashboard currently relying on the prometheus metric.
The new value starts at 0 with the introduction of this commit. Like the metric, the new field counts the executed wasm instructions, plus instruction overheads the scheduler uses (e.g. there is a base overhead per message).
While the instructions are tracked exactly internally, they are only exported in millions of instructions.
As a drive-by, this commit also fixes an issue where the metric/new total was not correctly tracked in the edge case of heap delta rate limiting kicking in.