From c9391be8076e7e07e717c9c9547f511c6232e971 Mon Sep 17 00:00:00 2001 From: Michael Weigelt Date: Tue, 23 Jun 2026 13:42:56 +0000 Subject: [PATCH 1/2] remove multiplier --- rs/config/src/embedders.rs | 7 ------- rs/embedders/src/wasmtime_embedder.rs | 8 +------- rs/embedders/tests/instrumentation.rs | 6 +----- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/rs/config/src/embedders.rs b/rs/config/src/embedders.rs index 167c0bfabbdb..2d65862bddcc 100644 --- a/rs/config/src/embedders.rs +++ b/rs/config/src/embedders.rs @@ -86,9 +86,6 @@ pub(crate) const DEFAULT_MAX_DIRTY_PAGES_WITHOUT_OPTIMIZATION: usize = (GIB as u /// Scheduling overhead for copying dirty pages, in instructions. pub(crate) const DIRTY_PAGE_COPY_OVERHEAD: NumInstructions = NumInstructions::new(3_000); -/// The overhead for dirty pages in Wasm64. -pub const WASM64_DIRTY_PAGE_OVERHEAD_MULTIPLIER: u64 = 4; - const KIB: u64 = 1024; const GIB: u64 = KIB * KIB * KIB; @@ -245,9 +242,6 @@ pub struct Config { /// The dirty page copying overhead, in instructions. pub dirty_page_copy_overhead: NumInstructions, - /// The dirty page overhead factor for Wasm64. - pub wasm64_dirty_page_overhead_multiplier: u64, - /// The maximum allowed size for an uncompressed canister Wasm module. pub wasm_max_size: NumBytes, @@ -298,7 +292,6 @@ impl Config { max_wasm_memory_size: NumBytes::new(MAX_WASM_MEMORY_IN_BYTES), max_wasm64_memory_size: NumBytes::new(MAX_WASM64_MEMORY_IN_BYTES), max_stable_memory_size: NumBytes::new(MAX_STABLE_MEMORY_IN_BYTES), - wasm64_dirty_page_overhead_multiplier: WASM64_DIRTY_PAGE_OVERHEAD_MULTIPLIER, } } } diff --git a/rs/embedders/src/wasmtime_embedder.rs b/rs/embedders/src/wasmtime_embedder.rs index f74097c71a1e..7d18740d980c 100644 --- a/rs/embedders/src/wasmtime_embedder.rs +++ b/rs/embedders/src/wasmtime_embedder.rs @@ -639,13 +639,7 @@ impl WasmtimeEmbedder { main_memory_type = WasmMemoryType::Wasm64; } - let dirty_page_overhead = match main_memory_type { - WasmMemoryType::Wasm32 => self.config.dirty_page_overhead, - WasmMemoryType::Wasm64 => NumInstructions::from( - self.config.dirty_page_overhead.get() - * self.config.wasm64_dirty_page_overhead_multiplier, - ), - }; + let dirty_page_overhead = self.config.dirty_page_overhead; let memory_trackers = sigsegv_memory_tracker( memories, diff --git a/rs/embedders/tests/instrumentation.rs b/rs/embedders/tests/instrumentation.rs index e3857b8c1e1a..aec3295b2d1b 100644 --- a/rs/embedders/tests/instrumentation.rs +++ b/rs/embedders/tests/instrumentation.rs @@ -813,14 +813,10 @@ fn run_charge_for_dirty_heap(wasm_memory_type: WasmMemoryType) { }, wasm_memory_type, ); - let mut cd = SchedulerConfig::application_subnet() + let cd = SchedulerConfig::application_subnet() .dirty_page_overhead .get(); - if let WasmMemoryType::Wasm64 = wasm_memory_type { - cd *= EmbeddersConfig::default().wasm64_dirty_page_overhead_multiplier; - } - // Both stores target Wasm page 0 (bytes 0 and 4096 are within the 64KB page), // so only one heap page-first-write event occurs. let overhead = deterministic_tracker_overhead(1, 0); From 4d50529afa4eb947de4f03789c9056819616a132 Mon Sep 17 00:00:00 2001 From: Michael Weigelt Date: Tue, 23 Jun 2026 15:12:48 +0000 Subject: [PATCH 2/2] adjust costs --- .../benches/system_api/execute_update.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rs/execution_environment/benches/system_api/execute_update.rs b/rs/execution_environment/benches/system_api/execute_update.rs index 367658c22e03..74529ff7a0f5 100644 --- a/rs/execution_environment/benches/system_api/execute_update.rs +++ b/rs/execution_environment/benches/system_api/execute_update.rs @@ -373,7 +373,7 @@ pub fn execute_update_bench(c: &mut Criterion) { Result::No, Wasm64::Enabled, ), // 10B max - 529004006 + common::deterministic_tracker_write_overhead(1), + 529001006 + common::deterministic_tracker_write_overhead(1), ), common::Benchmark( "wasm32/ic0_debug_print()/1B".into(), @@ -787,7 +787,7 @@ pub fn execute_update_bench(c: &mut Criterion) { Result::No, Wasm64::Enabled, ), - 517004006 + common::deterministic_tracker_write_overhead(1), + 517001006 + common::deterministic_tracker_write_overhead(1), ), common::Benchmark( "wasm32/ic0_msg_cycles_available()".into(), @@ -937,7 +937,7 @@ pub fn execute_update_bench(c: &mut Criterion) { Result::No, Wasm64::Enabled, ), - 19004006 + common::deterministic_tracker_write_overhead(1), + 19001006 + common::deterministic_tracker_write_overhead(1), ), common::Benchmark( "wasm32/ic0_is_controller()".into(), @@ -1027,7 +1027,7 @@ pub fn execute_update_bench(c: &mut Criterion) { Result::No, Wasm64::Enabled, ), - 519004006 + common::deterministic_tracker_write_overhead(1), + 519001006 + common::deterministic_tracker_write_overhead(1), ), common::Benchmark( "wasm32/ic0_cost_create_canister()".into(), @@ -1047,7 +1047,7 @@ pub fn execute_update_bench(c: &mut Criterion) { Result::No, Wasm64::Enabled, ), - 517004006 + common::deterministic_tracker_write_overhead(1), + 517001006 + common::deterministic_tracker_write_overhead(1), ), common::Benchmark( "wasm32/ic0_cost_http_request()".into(), @@ -1067,7 +1067,7 @@ pub fn execute_update_bench(c: &mut Criterion) { Result::No, Wasm64::Enabled, ), - 519004006 + common::deterministic_tracker_write_overhead(1), + 519001006 + common::deterministic_tracker_write_overhead(1), ), { let serialized_params = candid::encode_one(COST_HTTP_REQUEST_V2_PARAMS).unwrap(); @@ -1111,7 +1111,7 @@ pub fn execute_update_bench(c: &mut Criterion) { }, Wasm64::Enabled, ), - 10019004006 + common::deterministic_tracker_write_overhead(1), + 10019001006 + common::deterministic_tracker_write_overhead(1), ) }, common::Benchmark(