Skip to content

feat: Export million_round_instructions_total in subnet_metrics - #11587

Merged
schneiderstefan merged 4 commits into
masterfrom
stschnei/cycle-metrics
Sep 16, 2026
Merged

schneiderstefan merged 4 commits into
masterfrom
stschnei/cycle-metrics

Conversation

@schneiderstefan

Copy link
Copy Markdown
Contributor

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.

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.
@github-actions github-actions Bot added the feat label Sep 16, 2026
@schneiderstefan

Copy link
Copy Markdown
Contributor Author

Intended follow-up once this is rolled out: #11586

@zeropath-ai

zeropath-ai Bot commented Sep 16, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to c6df79f.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/execution_environment/src/execution_environment.rs
    Reporting new million_round_instructions_total in subnet metrics computation and mapping from metrics.round_instructions_total (div_ceil)
Enhancement ► rs/execution_environment/src/metrics.rs
    Add instructions() accessor to MeasurementScope
Enhancement ► rs/execution_environment/src/scheduler.rs
    Introduce accumulate_round_subnet_metrics to aggregate round metrics; update round_subnet metrics accumulation on exits
Enhancement ► rs/execution_environment/src/scheduler/tests/rate_limiting.rs
    Add test ensuring drained consensus queue messages are counted toward update_transactions_total and that round instructions are tracked across rounds
Enhancement ► rs/execution_environment/tests/execution_test.rs
    Update subnet metrics test to account for round_instructions_total and its relation to million rounding behavior
Enhancement ► rs/protobuf/def/state/metadata/v1/metadata.proto
    Add round_instructions_total field to SubnetMetrics (tag 13)
Enhancement ► rs/protobuf/src/gen/state/state.metadata.v1.rs
    Include optional round_instructions_total field in SubnetMetrics struct
Enhancement ► rs/replicated_state/src/metadata_state.rs
    Add round_instructions_total field to SubnetMetrics
Enhancement ► rs/replicated_state/src/metadata_state/proto.rs
    Serialize/deserialize round_instructions_total in SubnetMetrics
Enhancement ► rs/replicated_state/src/metadata_state/tests.rs
    Test decoding of zero when round_instructions_total field absent
Enhancement ► rs/state_manager/src/manifest/split/tests.rs
    Update expected size/hash for SYSTEM_METADATA_FILE and related entries due to new round_instructions_total field
Enhancement ► rs/state_manager/tests/state_manager.rs
    New test: round_instructions_total_survives_a_checkpoint
Enhancement ► rs/test_utilities/state/src/lib.rs
    Propagate round_instructions_total in SubnetMetrics generation for tests
Enhancement ► rs/types/management_canister_types/src/lib.rs
    Update SubnetMetricsArgs/docs to include million_round_instructions_total
Enhancement ► rs/types/management_canister_types/tests/ic.did
    Update DID interface to document million_round_instructions_total field

Comment thread rs/execution_environment/src/scheduler.rs Outdated
Comment thread rs/execution_environment/src/scheduler/tests/rate_limiting.rs Outdated
Comment thread rs/types/management_canister_types/tests/ic.did
Comment thread rs/execution_environment/src/scheduler.rs
Comment thread rs/execution_environment/src/scheduler/tests/rate_limiting.rs Outdated
@schneiderstefan
schneiderstefan added this pull request to the merge queue Sep 16, 2026
Merged via the queue into master with commit 2788b2b Sep 16, 2026
40 checks passed
@schneiderstefan
schneiderstefan deleted the stschnei/cycle-metrics branch September 16, 2026 16:09
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) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants