Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
})
Expand Down
18 changes: 1 addition & 17 deletions rs/replicated_state/src/replicated_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -686,22 +686,6 @@ impl ReplicatedState {
)
}

/// Time complexity: `O(n)` in the number of active canisters.
pub fn canister_accumulated_priorities(&self) -> BTreeMap<CanisterId, AccumulatedPriority> {
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.
Expand Down
Loading