From e8ade9d037ccbbbb8fb72979b7d88113a7600741 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Fri, 13 Feb 2026 16:06:57 +0100 Subject: [PATCH 1/8] frame-omni-bencher: enable jemalloc-allocator Fix huge benchmark regression for storage-heavy extrinsics, enabling jemalloc-allocator for benchmarking, marked as option in the scope of PR #10590. --- Cargo.lock | 1 + substrate/utils/frame/omni-bencher/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 4c125748530f7..8369eb15caa62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6849,6 +6849,7 @@ dependencies = [ "frame-benchmarking-cli", "sc-chain-spec", "sc-cli", + "sc-client-db", "sp-genesis-builder", "sp-runtime", "sp-statement-store", diff --git a/substrate/utils/frame/omni-bencher/Cargo.toml b/substrate/utils/frame/omni-bencher/Cargo.toml index 5d9cf766b3286..a685361c39b85 100644 --- a/substrate/utils/frame/omni-bencher/Cargo.toml +++ b/substrate/utils/frame/omni-bencher/Cargo.toml @@ -16,6 +16,7 @@ clap = { features = ["derive"], workspace = true } cumulus-primitives-proof-size-hostfunction = { workspace = true, default-features = true } frame-benchmarking-cli = { workspace = true } sc-cli = { workspace = true, default-features = true } +sc-client-db = { features = ["jemalloc-allocator"], workspace = true } sp-runtime = { workspace = true, default-features = true } sp-statement-store = { workspace = true, default-features = true } tracing-subscriber = { workspace = true } From 5650679c4c462d2430856d2e3cd6d2b94a485ba6 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 15:16:00 +0000 Subject: [PATCH 2/8] Update from github-actions[bot] running command 'prdoc --audience runtime_dev --bump patch' --- prdoc/pr_11069.prdoc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 prdoc/pr_11069.prdoc diff --git a/prdoc/pr_11069.prdoc b/prdoc/pr_11069.prdoc new file mode 100644 index 0000000000000..debc865bf774e --- /dev/null +++ b/prdoc/pr_11069.prdoc @@ -0,0 +1,9 @@ +title: 'frame-omni-bencher: enable jemalloc-allocator' +doc: +- audience: Runtime Dev + description: "Fix huge benchmark regression for storage-heavy extrinsics, enabling\ + \ jemalloc-allocator for benchmarking, marked as option in the scope of PR #10590.\r\ + \n" +crates: +- name: frame-omni-bencher + bump: patch From c2df3714f9f2057b51ca04a8050c0a82cd3a2165 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Fri, 13 Feb 2026 16:21:15 +0100 Subject: [PATCH 3/8] fix prdoc --- prdoc/pr_11069.prdoc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/prdoc/pr_11069.prdoc b/prdoc/pr_11069.prdoc index debc865bf774e..5fbc0b566020b 100644 --- a/prdoc/pr_11069.prdoc +++ b/prdoc/pr_11069.prdoc @@ -1,9 +1,8 @@ -title: 'frame-omni-bencher: enable jemalloc-allocator' +title: 'frame-omni-bencher: enable sc-client-db with jemalloc-allocator' doc: - audience: Runtime Dev - description: "Fix huge benchmark regression for storage-heavy extrinsics, enabling\ - \ jemalloc-allocator for benchmarking, marked as option in the scope of PR #10590.\r\ - \n" + description: |- + Fix huge benchmark regression for storage-heavy extrinsics, enabling sc-client-db with jemalloc-allocator for omni-bencher, marked as optional in the scope of PR #10590. crates: - name: frame-omni-bencher bump: patch From 6266454a1378836a4741b16784024fa80f505320 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Fri, 13 Feb 2026 16:34:28 +0100 Subject: [PATCH 4/8] revert warmup key w/r introduced by PR10947 --- prdoc/pr_11069.prdoc | 3 +++ substrate/frame/benchmarking/src/utils.rs | 13 ------------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/prdoc/pr_11069.prdoc b/prdoc/pr_11069.prdoc index 5fbc0b566020b..e799dffe7b5b8 100644 --- a/prdoc/pr_11069.prdoc +++ b/prdoc/pr_11069.prdoc @@ -3,6 +3,9 @@ doc: - audience: Runtime Dev description: |- Fix huge benchmark regression for storage-heavy extrinsics, enabling sc-client-db with jemalloc-allocator for omni-bencher, marked as optional in the scope of PR #10590. + Revert also the dummy write/read workaround at the end of commit_db() introduced by #10947. crates: - name: frame-omni-bencher bump: patch +- name: frame-benchmarking + bump: patch diff --git a/substrate/frame/benchmarking/src/utils.rs b/substrate/frame/benchmarking/src/utils.rs index c081bc7af682c..acd2f0401302a 100644 --- a/substrate/frame/benchmarking/src/utils.rs +++ b/substrate/frame/benchmarking/src/utils.rs @@ -290,19 +290,6 @@ pub trait Benchmarking { /// Commit pending storage changes to the trie database and clear the database cache. fn commit_db(&mut self) { self.commit(); - - // Warmup the memory allocator after bulk deallocation. - // After draining the overlay with many entries, the first new allocation can trigger memory - // defragmentation. The warmup key is whitelisted so these operations don't appear in - // benchmark results. - const WARMUP_KEY: &[u8] = b":benchmark_warmup:"; - let mut whitelist = self.get_whitelist(); - if !whitelist.iter().any(|k| k.key == WARMUP_KEY) { - whitelist.push(WARMUP_KEY.to_vec().into()); - self.set_whitelist(whitelist); - } - self.place_storage(WARMUP_KEY.to_vec(), Some(vec![0u8; 32])); - self.place_storage(WARMUP_KEY.to_vec(), None); } /// Get the read/write count. From c07ad08f15918295fdb8d1b8964fe42889fd8fb1 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Fri, 13 Feb 2026 18:36:34 +0100 Subject: [PATCH 5/8] use polkadot-jemalloc-shim instead --- Cargo.lock | 2 +- prdoc/pr_11069.prdoc | 4 ++-- substrate/utils/frame/omni-bencher/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e606a6a30c55f..8be264efee579 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6847,9 +6847,9 @@ dependencies = [ "cumulus-primitives-proof-size-hostfunction", "cumulus-test-runtime", "frame-benchmarking-cli", + "polkadot-jemalloc-shim", "sc-chain-spec", "sc-cli", - "sc-client-db", "sp-genesis-builder", "sp-runtime", "sp-statement-store", diff --git a/prdoc/pr_11069.prdoc b/prdoc/pr_11069.prdoc index e799dffe7b5b8..1e32bcd839bda 100644 --- a/prdoc/pr_11069.prdoc +++ b/prdoc/pr_11069.prdoc @@ -1,8 +1,8 @@ -title: 'frame-omni-bencher: enable sc-client-db with jemalloc-allocator' +title: 'frame-omni-bencher: enable jemalloc-allocator' doc: - audience: Runtime Dev description: |- - Fix huge benchmark regression for storage-heavy extrinsics, enabling sc-client-db with jemalloc-allocator for omni-bencher, marked as optional in the scope of PR #10590. + Fix huge benchmark regression for storage-heavy extrinsics, enabling jemalloc-allocator via polkadot-jemalloc-shim for omni-bencher, marked as optional in the scope of PR #10590. Revert also the dummy write/read workaround at the end of commit_db() introduced by #10947. crates: - name: frame-omni-bencher diff --git a/substrate/utils/frame/omni-bencher/Cargo.toml b/substrate/utils/frame/omni-bencher/Cargo.toml index a685361c39b85..83cf76cfabb39 100644 --- a/substrate/utils/frame/omni-bencher/Cargo.toml +++ b/substrate/utils/frame/omni-bencher/Cargo.toml @@ -15,8 +15,8 @@ workspace = true clap = { features = ["derive"], workspace = true } cumulus-primitives-proof-size-hostfunction = { workspace = true, default-features = true } frame-benchmarking-cli = { workspace = true } +polkadot-jemalloc-shim = { workspace = true, features = ["jemalloc-allocator"] } sc-cli = { workspace = true, default-features = true } -sc-client-db = { features = ["jemalloc-allocator"], workspace = true } sp-runtime = { workspace = true, default-features = true } sp-statement-store = { workspace = true, default-features = true } tracing-subscriber = { workspace = true } From e0e58b9833451888bbcb2bc386b94de2d4243092 Mon Sep 17 00:00:00 2001 From: Paolo La Camera Date: Fri, 13 Feb 2026 18:40:18 +0100 Subject: [PATCH 6/8] add a comment --- substrate/utils/frame/omni-bencher/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/substrate/utils/frame/omni-bencher/Cargo.toml b/substrate/utils/frame/omni-bencher/Cargo.toml index 83cf76cfabb39..de6263224dd1f 100644 --- a/substrate/utils/frame/omni-bencher/Cargo.toml +++ b/substrate/utils/frame/omni-bencher/Cargo.toml @@ -15,6 +15,7 @@ workspace = true clap = { features = ["derive"], workspace = true } cumulus-primitives-proof-size-hostfunction = { workspace = true, default-features = true } frame-benchmarking-cli = { workspace = true } +# Jemalloc as global allocator prevents huge benchmark regression for storage-heavy extrinsics. polkadot-jemalloc-shim = { workspace = true, features = ["jemalloc-allocator"] } sc-cli = { workspace = true, default-features = true } sp-runtime = { workspace = true, default-features = true } From 961fa75825cac3c1647f6dea9f79c018144302fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 15 Feb 2026 23:57:11 +0100 Subject: [PATCH 7/8] Restore jemalloc allocator for Linux target Reintroduced polkadot-jemalloc-shim as a global allocator for Linux to prevent benchmark regression. --- substrate/utils/frame/omni-bencher/Cargo.toml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/substrate/utils/frame/omni-bencher/Cargo.toml b/substrate/utils/frame/omni-bencher/Cargo.toml index de6263224dd1f..453791a9e91bc 100644 --- a/substrate/utils/frame/omni-bencher/Cargo.toml +++ b/substrate/utils/frame/omni-bencher/Cargo.toml @@ -15,13 +15,17 @@ workspace = true clap = { features = ["derive"], workspace = true } cumulus-primitives-proof-size-hostfunction = { workspace = true, default-features = true } frame-benchmarking-cli = { workspace = true } -# Jemalloc as global allocator prevents huge benchmark regression for storage-heavy extrinsics. -polkadot-jemalloc-shim = { workspace = true, features = ["jemalloc-allocator"] } + +polkadot-jemalloc-shim = { workspace = true } sc-cli = { workspace = true, default-features = true } sp-runtime = { workspace = true, default-features = true } sp-statement-store = { workspace = true, default-features = true } tracing-subscriber = { workspace = true } +[target.'cfg(target_os = "linux")'.dependencies] +# Jemalloc as global allocator prevents huge benchmark regression for storage-heavy extrinsics. +polkadot-jemalloc-shim = { workspace = true, features = ["jemalloc-allocator"] } + [dev-dependencies] assert_cmd = { workspace = true } cumulus-test-runtime = { workspace = true } From 8b1c9d3dd3f1908b5a4108cb59a877e7cddb324a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 15 Feb 2026 23:57:27 +0100 Subject: [PATCH 8/8] Remove unused dependency from Cargo.toml Removed an unused dependency from the Cargo.toml file. --- substrate/utils/frame/omni-bencher/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/utils/frame/omni-bencher/Cargo.toml b/substrate/utils/frame/omni-bencher/Cargo.toml index 453791a9e91bc..d84829a5a6a5e 100644 --- a/substrate/utils/frame/omni-bencher/Cargo.toml +++ b/substrate/utils/frame/omni-bencher/Cargo.toml @@ -15,7 +15,6 @@ workspace = true clap = { features = ["derive"], workspace = true } cumulus-primitives-proof-size-hostfunction = { workspace = true, default-features = true } frame-benchmarking-cli = { workspace = true } - polkadot-jemalloc-shim = { workspace = true } sc-cli = { workspace = true, default-features = true } sp-runtime = { workspace = true, default-features = true }