Skip to content

Commit

Permalink
refactor: EXC-1735: Move ongoing_long_install_code into `drain_subn…
Browse files Browse the repository at this point in the history
…et_queues` (#1761)

This simplifies the inner round, without affecting functionality.
  • Loading branch information
berestovskyy authored Oct 1, 2024
1 parent 10b8809 commit 54c3542
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
25 changes: 11 additions & 14 deletions rs/execution_environment/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,19 @@ impl SchedulerImpl {
csprng: &mut Csprng,
round_limits: &mut RoundLimits,
measurement_scope: &MeasurementScope,
ongoing_long_install_code: bool,
registry_settings: &RegistryExecutionSettings,
idkg_subnet_public_keys: &BTreeMap<MasterPublicKeyId, MasterPublicKey>,
) -> ReplicatedState {
let ongoing_long_install_code =
state
.canister_states
.iter()
.any(|(_canister_id, canister)| match canister.next_execution() {
NextExecution::None | NextExecution::StartNew | NextExecution::ContinueLong => {
false
}
NextExecution::ContinueInstallCode => true,
});
loop {
let mut available_subnet_messages = false;
let mut loop_detector = state.subnet_queues_loop_detector();
Expand Down Expand Up @@ -654,33 +663,21 @@ impl SchedulerImpl {
let mut state = loop {
// Execute subnet messages.
// If new messages are inducted into the subnet input queues,
// they are processed until the subbnet messages' instruction limit is reached.
// they are processed until the subnet messages' instruction limit is reached.
{
let subnet_measurement_scope = MeasurementScope::nested(
&self.metrics.round_subnet_queue,
root_measurement_scope,
);

// TODO(EXC-1517): Improve inner loop preparation.
let ongoing_long_install_code =
state
.canister_states
.iter()
.any(|(_canister_id, canister)| match canister.next_execution() {
NextExecution::None
| NextExecution::StartNew
| NextExecution::ContinueLong => false,
NextExecution::ContinueInstallCode => true,
});

let mut subnet_round_limits = scheduler_round_limits.subnet_round_limits();
if !subnet_round_limits.reached() {
state = self.drain_subnet_queues(
state,
csprng,
&mut subnet_round_limits,
&subnet_measurement_scope,
ongoing_long_install_code,
registry_settings,
idkg_subnet_public_keys,
);
Expand Down
1 change: 0 additions & 1 deletion rs/execution_environment/src/scheduler/test_utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ impl SchedulerTest {
&mut csprng,
&mut round_limits,
&measurements,
false,
self.registry_settings(),
&BTreeMap::new(),
)
Expand Down

0 comments on commit 54c3542

Please sign in to comment.