Skip to content

Commit

Permalink
Merge branch 'ulan/run-757' into 'master'
Browse files Browse the repository at this point in the history
RUN-757: Add a metric for total reserved balances

This MR introduces `scheduler_canister_reserved_balance_cycles_total`
similar to the existing `scheduler_canister_balance_cycles_total`.

The metric is recorded in exactly the same way as the existing metric. 

See merge request dfinity-lab/public/ic!14602
  • Loading branch information
ulan committed Sep 8, 2023
2 parents 0b83d19 + 390f967 commit 183369a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rs/execution_environment/src/scheduler.rs
Expand Up @@ -1545,6 +1545,7 @@ impl Scheduler for SchedulerImpl {
{
let mut cycles_out_sum = Cycles::zero();
let mut total_canister_balance = Cycles::zero();
let mut total_canister_reserved_balance = Cycles::zero();
let mut total_canister_history_memory_usage = NumBytes::new(0);
let mut total_canister_memory_usage = NumBytes::new(0);
for canister in state.canisters_iter_mut() {
Expand Down Expand Up @@ -1576,6 +1577,7 @@ impl Scheduler for SchedulerImpl {
total_canister_history_memory_usage += canister.canister_history_memory_usage();
total_canister_memory_usage += canister.memory_usage();
total_canister_balance += canister.system_state.balance();
total_canister_reserved_balance += canister.system_state.reserved_balance();
cycles_out_sum += canister.system_state.queues().output_queue_cycles();
}
cycles_out_sum += total_canister_balance;
Expand All @@ -1584,6 +1586,10 @@ impl Scheduler for SchedulerImpl {
.total_canister_balance
.set(total_canister_balance.get() as f64);

self.metrics
.total_canister_reserved_balance
.set(total_canister_reserved_balance.get() as f64);

// TODO(EXC-1124): Re-enable the check below once it's fixed.
//
// Check that amount of cycles at the beginning of the round (balances and cycles from input messages) is bigger or equal
Expand Down
5 changes: 5 additions & 0 deletions rs/execution_environment/src/scheduler/scheduler_metrics.rs
Expand Up @@ -84,6 +84,7 @@ pub(super) struct SchedulerMetrics {
pub(super) scheduler_accumulated_priority_deviation: Gauge,
pub(super) subnet_memory_usage_invariant: IntCounter,
pub(super) total_canister_balance: Gauge,
pub(super) total_canister_reserved_balance: Gauge,
pub(super) canister_paused_execution: Histogram,
pub(super) canister_aborted_execution: Histogram,
pub(super) canister_paused_install_code: Histogram,
Expand Down Expand Up @@ -555,6 +556,10 @@ impl SchedulerMetrics {
"scheduler_canister_balance_cycles_total",
"Total canister balance in Cycles.",
),
total_canister_reserved_balance: metrics_registry.gauge(
"scheduler_canister_reserved_balance_cycles_total",
"Total canister reserved balance in Cycles.",
),
canister_paused_execution: dts_pause_or_abort_histogram(
"scheduler_canister_paused_execution",
"Number of canisters that have a paused execution.",
Expand Down

0 comments on commit 183369a

Please sign in to comment.