diff --git a/rs/canister_sandbox/src/replica_controller/sandboxed_execution_controller.rs b/rs/canister_sandbox/src/replica_controller/sandboxed_execution_controller.rs index 6e775b324658..420a629a14ac 100644 --- a/rs/canister_sandbox/src/replica_controller/sandboxed_execution_controller.rs +++ b/rs/canister_sandbox/src/replica_controller/sandboxed_execution_controller.rs @@ -2068,11 +2068,7 @@ fn evict_sandbox_processes( Backend::Empty => false, }); - let scheduler_priorities = state_reader - .get_latest_state() - .get_ref() - .canister_accumulated_priorities(); - + let state = state_reader.get_latest_state(); let min_scheduler_priority = AccumulatedPriority::new(i64::MIN); let candidates: Vec<_> = backends @@ -2082,10 +2078,12 @@ fn evict_sandbox_processes( id: *id, last_used: stats.last_used, rss: stats.rss, - scheduler_priority: *scheduler_priorities - .get(id) - // This should happen only if the canister is deleted. - .unwrap_or(&min_scheduler_priority), + scheduler_priority: if state.get_ref().canister_state(id).is_some() { + state.get_ref().canister_priority(id).accumulated_priority + } else { + // Canister was deleted. + min_scheduler_priority + }, }), Backend::Evicted { .. } | Backend::Empty => None, }) diff --git a/rs/replicated_state/src/replicated_state.rs b/rs/replicated_state/src/replicated_state.rs index ebee68d7506b..835860acbef7 100644 --- a/rs/replicated_state/src/replicated_state.rs +++ b/rs/replicated_state/src/replicated_state.rs @@ -25,7 +25,7 @@ use ic_registry_resource_limits::ResourceLimits; use ic_registry_routing_table::RoutingTable; use ic_registry_subnet_type::SubnetType; use ic_types::{ - AccumulatedPriority, CanisterId, NumBytes, SubnetId, Time, + CanisterId, NumBytes, SubnetId, Time, batch::{ConsensusResponse, RawQueryStats}, consensus::idkg::IDkgMasterPublicKeyId, ingress::IngressStatus, @@ -686,22 +686,6 @@ impl ReplicatedState { ) } - /// Time complexity: `O(n)` in the number of active canisters. - pub fn canister_accumulated_priorities(&self) -> BTreeMap { - self.canister_states - .keys() - .map(|canister_id| { - ( - *canister_id, - self.metadata - .subnet_schedule - .get(canister_id) - .accumulated_priority, - ) - }) - .collect() - } - /// Prunes the canister priorities of deleted canisters; and those that have /// all-zero accumulated priority, priority credit, heap delta and install code /// debits, and do not have a long-running execution.