Skip to content

Commit

Permalink
EXC-1516: Add new metric for advance install code executions
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandraZapuc committed Feb 5, 2024
1 parent 2211428 commit 5634346
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 7 deletions.
6 changes: 4 additions & 2 deletions rs/execution_environment/src/scheduler.rs
Expand Up @@ -1606,8 +1606,10 @@ impl Scheduler for SchedulerImpl {

// Subnet queues: execute long running install code call if present.
{
let measurement_scope =
MeasurementScope::nested(&self.metrics.round_subnet_queue, &root_measurement_scope);
let measurement_scope = MeasurementScope::nested(
&self.metrics.round_advance_long_install_code,
&root_measurement_scope,
);

let mut subnet_round_limits = scheduler_round_limits.subnet_round_limits();
state = self.advance_long_running_install_code(
Expand Down
27 changes: 27 additions & 0 deletions rs/execution_environment/src/scheduler/scheduler_metrics.rs
Expand Up @@ -70,6 +70,7 @@ pub(super) struct SchedulerMetrics {
pub(super) round_consensus_queue: ScopedMetrics,
pub(super) round_postponed_raw_rand_queue: ScopedMetrics,
pub(super) round_subnet_queue: ScopedMetrics,
pub(super) round_advance_long_install_code: ScopedMetrics,
pub(super) round_scheduling_duration: Histogram,
pub(super) round_update_sign_with_ecdsa_contexts_duration: Histogram,
pub(super) round_inner: ScopedMetrics,
Expand Down Expand Up @@ -404,6 +405,32 @@ impl SchedulerMetrics {
metrics_registry,
),
},
round_advance_long_install_code: ScopedMetrics {
duration: duration_histogram(
"execution_round_advance_long_install_code_duration_seconds",
"The duration of advancing an in progress long install code in \
an execution round",
metrics_registry,
),
instructions: instructions_histogram(
"execution_round_advance_long_install_code_instructions",
"The number of instructions executed during advancing \
an in progress install code in an execution round",
metrics_registry,
),
slices: slices_histogram(
"execution_round_advance_long_install_code_slices",
"The number of slices executed executed during advancing \
an in progress install code in an execution round",
metrics_registry,
),
messages: messages_histogram(
"execution_round_advance_long_install_code_messages",
"The number of messages executed during advancing \
an in progress install code in an execution round",
metrics_registry,
),
},
round_scheduling_duration: duration_histogram(
"execution_round_scheduling_duration_seconds",
"The duration of execution round scheduling in seconds.",
Expand Down
48 changes: 43 additions & 5 deletions rs/execution_environment/src/scheduler/tests.rs
Expand Up @@ -2502,16 +2502,30 @@ fn execution_round_metrics_are_recorded() {
13
);
assert_eq!(test.state().metadata.subnet_metrics.num_canisters, 3);
assert_eq!(3, metrics.round_subnet_queue.duration.get_sample_count());
assert_eq!(
3,
1,
metrics
.round_advance_long_install_code
.duration
.get_sample_count()
);
assert_eq!(
1,
metrics
.round_advance_long_install_code
.messages
.get_sample_count()
);
assert_eq!(2, metrics.round_subnet_queue.duration.get_sample_count());
assert_eq!(
2,
metrics.round_subnet_queue.instructions.get_sample_count()
);
assert_eq!(
30,
metrics.round_subnet_queue.instructions.get_sample_sum() as u64,
);
assert_eq!(3, metrics.round_subnet_queue.messages.get_sample_count());
assert_eq!(2, metrics.round_subnet_queue.messages.get_sample_count());
assert_eq!(
3,
metrics.round_subnet_queue.messages.get_sample_sum() as u64,
Expand Down Expand Up @@ -4317,7 +4331,15 @@ fn dts_allow_only_one_long_install_code_execution_at_any_time() {
.round_subnet_queue
.slices
.get_sample_sum(),
2.0
1.0
);
assert_eq!(
test.scheduler()
.metrics
.round_advance_long_install_code
.slices
.get_sample_sum(),
1.0
);
assert_eq!(
test.scheduler()
Expand Down Expand Up @@ -4369,16 +4391,32 @@ fn dts_allow_only_one_long_install_code_execution_at_any_time() {
.round_subnet_queue
.slices
.get_sample_sum(),
4.0
2.0
);
assert_eq!(
test.scheduler()
.metrics
.round_subnet_queue
.messages
.get_sample_sum(),
1.0
);
assert_eq!(
test.scheduler()
.metrics
.round_advance_long_install_code
.slices
.get_sample_sum(),
2.0
);
assert_eq!(
test.scheduler()
.metrics
.round_advance_long_install_code
.messages
.get_sample_sum(),
1.0
);

// Execute another round to refresh the metrics
test.execute_round(ExecutionRoundType::OrdinaryRound);
Expand Down

0 comments on commit 5634346

Please sign in to comment.