Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

RUN-636: Add per-call instruction counter #172

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spec/changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[#unreleased]
=== ∞ (unreleased)
* Spec: User delegations include a principal scope
* Spec: Add per-call context performance counter

[#0_18_9]
=== 0.18.9 (2022-12-06)
Expand Down
12 changes: 6 additions & 6 deletions spec/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1461,19 +1461,17 @@ Passing zero as an argument to the function deactivates the timer and thus preve
[#system-api-performance-counter]
=== Performance counter

The canister can query the "performance counter", which is a deterministic monotonically increasing integer approximating the amount of work the canister has done since the beginning of the current execution.
The canister can query one of the "performance counters", which is a deterministic monotonically increasing integer approximating the amount of work the canister has done. Developers might use this data to profile and optimize the canister performance.

`+ic0.performance_counter : (counter_type : i32) -> i64+`

The argument `type` decides which performance counter to return:

* 0 : instruction counter. The number of WebAssembly instructions the system has determined that the canister has executed.
* 0 : current execution instruction counter. The number of WebAssembly instructions the canister has executed since the beginning of the current <<rule-message-execution>>.

In the future, we might expose more performance counters.
* 1 : call context instruction counter. The number of WebAssembly instructions the canister has executed within the call context of the current <<rule-message-execution>> since <<call-context-creation>>. The counter monotonically increases across all <<rule-message-execution,message executions>> in the call context until the corresponding <<call-context-removal,call context is removed>>.

The system resets the counter at the beginning of each <<entry-points>> invocation.

The main purpose of this counter is to facilitate in-canister performance profiling.
In the future, the IC might expose more performance counters.

[#system-api-controller-check]
=== Controller check
Expand Down Expand Up @@ -2857,6 +2855,7 @@ State after::
....


[#call-context-creation]
==== Call context creation

Before invoking a heartbeat, a global timer, or a message to a public entry point, a call context is created for bookkeeping purposes.
Expand Down Expand Up @@ -3169,6 +3168,7 @@ S with
}
....

[#call-context-removal]
==== Call context removal

If there is no call, downstream call context, or response that references a call context, and the call context does not need to respond (because it has already responded or its origin is a system task that does not await a response), then the call context can be removed.
Expand Down