diff --git a/Cargo.lock b/Cargo.lock index 7a6301a0710..9354fe0fbf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2731,7 +2731,7 @@ checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" [[package]] name = "dlmalloc" version = "0.1.4" -source = "git+https://github.com/gear-tech/dlmalloc-rust.git#15352f969112faa463302f2490bbb7f6e1cb904d" +source = "git+https://github.com/gear-tech/dlmalloc-rust.git?branch=holykol/free-range-support#2abd7fe1e8974d9740bfd1b413c8bed19752bbb4" dependencies = [ "libc", "libc-print", diff --git a/Cargo.toml b/Cargo.toml index fd21ce7fb84..15e74662d87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,7 +105,7 @@ colored = "2.0.0" const-str = "0.5" derive_more = "0.99.17" dirs = "4.0.0" -dlmalloc = { git = "https://github.com/gear-tech/dlmalloc-rust.git" } +dlmalloc = { git = "https://github.com/gear-tech/dlmalloc-rust.git", branch = "holykol/free-range-support"} dyn-clonable = "0.9.0" enum-iterator = "1.4.0" env_logger = "0.10" diff --git a/pallets/gear/src/benchmarking/mod.rs b/pallets/gear/src/benchmarking/mod.rs index e124e189833..d94c33cb680 100644 --- a/pallets/gear/src/benchmarking/mod.rs +++ b/pallets/gear/src/benchmarking/mod.rs @@ -827,9 +827,9 @@ benchmarks! { } free_range { - let p in 0..512; + let r in 0..512; let mut res = None; - let exec = Benches::::free_range(p, 1)?; + let exec = Benches::::free_range(r, 1)?; }: { res.replace(run_process(exec)); } diff --git a/pallets/gear/src/benchmarking/syscalls.rs b/pallets/gear/src/benchmarking/syscalls.rs index 07ee04be09b..9ffddd77319 100644 --- a/pallets/gear/src/benchmarking/syscalls.rs +++ b/pallets/gear/src/benchmarking/syscalls.rs @@ -266,8 +266,6 @@ where pub fn free_range(repetitions: u32, pages_per_call: u32) -> Result, &'static str> { use Instruction::*; - const MAX_PAGES_OVERRIDE: u16 = u16::MAX; - let mut instructions = vec![]; for _ in 0..API_BENCHMARK_BATCH_SIZE { @@ -277,7 +275,7 @@ where unreachable_condition(&mut instructions, I32Eq); // if alloc returns -1 then it's error // free them in steps - let mut i = 1; + let mut i = 0; for _ in 0..repetitions { instructions.extend([ I32Const(i), @@ -297,7 +295,7 @@ where ..Default::default() }; - Self::prepare_handle_override_max_pages(module, 0, MAX_PAGES_OVERRIDE.into()) + Self::prepare_handle(module, 0) } pub fn gr_reserve_gas(r: u32) -> Result, &'static str> { diff --git a/runtime/vara/src/tests.rs b/runtime/vara/src/tests.rs index 12a84112af2..06213e932aa 100644 --- a/runtime/vara/src/tests.rs +++ b/runtime/vara/src/tests.rs @@ -141,7 +141,7 @@ fn page_costs_heuristic_test() { lazy_pages_signal_write_after_read: 10_650_000.into(), lazy_pages_host_func_read: 29_000_000.into(), lazy_pages_host_func_write: 33_000_000.into(), - lazy_pages_host_func_write_after_read: 11_000_000.into(), + lazy_pages_host_func_write_after_read: 9_000_000.into(), load_page_data: 10_800_000.into(), upload_page_data: 104_000_000.into(), static_page: 100.into(),