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
33 changes: 13 additions & 20 deletions rs/execution_environment/src/canister_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,16 +966,26 @@ impl CanisterManager {
canister,
Some(round_limits),
time,
AddCanisterChangeToHistory::Yes(origin),
Arc::clone(&self.fd_factory),
);

let available_execution_memory_change = canister.add_canister_change(
time,
origin,
CanisterChangeDetails::CanisterCodeUninstall,
);
round_limits
.subnet_available_memory
.update_execution_memory_unchecked(available_execution_memory_change);

crate::util::process_responses(
rejects,
state,
Arc::clone(&self.ingress_history_writer),
self.log.clone(),
canister_not_found_error,
);

Ok(())
}

Expand Down Expand Up @@ -3106,9 +3116,8 @@ fn get_response_size(kind: &CanisterSnapshotDataKind) -> Result<u64, CanisterMan
pub fn uninstall_canister(
log: &ReplicaLogger,
canister: &mut CanisterState,
mut round_limits: Option<&mut RoundLimits>,
round_limits: Option<&mut RoundLimits>,
time: Time,
add_canister_change: AddCanisterChangeToHistory,
fd_factory: Arc<dyn PageAllocatorFileDescriptor>,
) -> Vec<Response> {
let old_allocated_bytes = canister.memory_allocated_bytes();
Expand All @@ -3133,7 +3142,7 @@ pub fn uninstall_canister(
let new_allocated_bytes = canister.memory_allocated_bytes();
debug_assert!(new_allocated_bytes <= old_allocated_bytes);

if let Some(round_limits) = round_limits.as_deref_mut() {
if let Some(round_limits) = round_limits {
let deallocated_bytes = old_allocated_bytes.saturating_sub(&new_allocated_bytes);
round_limits.subnet_available_memory.increment(
deallocated_bytes,
Expand All @@ -3142,22 +3151,6 @@ pub fn uninstall_canister(
);
}

match add_canister_change {
AddCanisterChangeToHistory::Yes(origin) => {
let available_execution_memory_change = canister.add_canister_change(
time,
origin,
CanisterChangeDetails::CanisterCodeUninstall,
);
if let Some(round_limits) = round_limits {
round_limits
.subnet_available_memory
.update_execution_memory_unchecked(available_execution_memory_change);
}
}
AddCanisterChangeToHistory::No => {}
};

let canister_id = canister.canister_id();

canister
Expand Down
8 changes: 3 additions & 5 deletions rs/execution_environment/src/canister_manager/tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
IngressHistoryWriterImpl, RoundLimits, as_num_instructions,
canister_manager::{
AddCanisterChangeToHistory, CanisterManager, CanisterManagerError, CanisterMgrConfig,
DtsInstallCodeResult, InstallCodeContext, MAX_SLICE_SIZE_BYTES, StopCanisterResult,
WasmSource, uninstall_canister,
CanisterManager, CanisterManagerError, CanisterMgrConfig, DtsInstallCodeResult,
InstallCodeContext, MAX_SLICE_SIZE_BYTES, StopCanisterResult, WasmSource,
uninstall_canister,
},
canister_settings::CanisterSettings,
execution_environment::{CompilationCostHandling, RoundCounters, as_round_instructions},
Expand Down Expand Up @@ -2286,7 +2286,6 @@ fn uninstall_canister_doesnt_respond_to_responded_call_contexts() {
.build(),
None,
UNIX_EPOCH,
AddCanisterChangeToHistory::No,
Arc::new(TestPageAllocatorFileDescriptorImpl),
),
Vec::new()
Expand All @@ -2313,7 +2312,6 @@ fn uninstall_canister_responds_to_unresponded_call_contexts() {
.build(),
None,
UNIX_EPOCH,
AddCanisterChangeToHistory::No,
Arc::new(TestPageAllocatorFileDescriptorImpl),
)[0],
Response::Ingress(IngressResponse {
Expand Down
6 changes: 0 additions & 6 deletions rs/execution_environment/src/canister_manager/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,6 @@ impl TryFrom<(CanisterChangeOrigin, InstallCodeArgsV2)> for InstallCodeContext {
}
}

/// Indicates whether `uninstall_canister` should push a canister change (with a given change origin) to canister history.
pub enum AddCanisterChangeToHistory {
Yes(CanisterChangeOrigin),
No,
}

pub(crate) struct UploadChunkResult {
pub(crate) reply: UploadChunkReply,
pub(crate) heap_delta_increase: NumBytes,
Expand Down
3 changes: 1 addition & 2 deletions rs/execution_environment/src/scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
canister_manager::{types::AddCanisterChangeToHistory, uninstall_canister},
canister_manager::uninstall_canister,
execution_environment::{
ExecuteCanisterResult, ExecutionEnvironment, RoundInstructions, RoundLimits,
as_num_instructions, as_round_instructions, execute_canister,
Expand Down Expand Up @@ -934,7 +934,6 @@ impl SchedulerImpl {
canister,
None, /* we're at the end of a round so no need to update round limits */
state_time,
AddCanisterChangeToHistory::No,
Arc::clone(&self.fd_factory),
));
canister.scheduler_state.compute_allocation = ComputeAllocation::zero();
Expand Down
Loading