Skip to content

Commit f6dd735

Browse files
paritytech-release-backport-bot[bot]sigurpolgithub-actions[bot]bkchr
authored
[stable2603] Backport #11069 (#11074)
Backport #11069 into `stable2603` from sigurpol. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Paolo La Camera <paolo@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de>
1 parent 584a364 commit f6dd735

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prdoc/pr_11069.prdoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
title: 'frame-omni-bencher: enable jemalloc-allocator'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
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.
6+
Revert also the dummy write/read workaround at the end of commit_db() introduced by #10947.
7+
crates:
8+
- name: frame-omni-bencher
9+
bump: patch
10+
- name: frame-benchmarking
11+
bump: patch

substrate/frame/benchmarking/src/utils.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,6 @@ pub trait Benchmarking {
290290
/// Commit pending storage changes to the trie database and clear the database cache.
291291
fn commit_db(&mut self) {
292292
self.commit();
293-
294-
// Warmup the memory allocator after bulk deallocation.
295-
// After draining the overlay with many entries, the first new allocation can trigger memory
296-
// defragmentation. The warmup key is whitelisted so these operations don't appear in
297-
// benchmark results.
298-
const WARMUP_KEY: &[u8] = b":benchmark_warmup:";
299-
let mut whitelist = self.get_whitelist();
300-
if !whitelist.iter().any(|k| k.key == WARMUP_KEY) {
301-
whitelist.push(WARMUP_KEY.to_vec().into());
302-
self.set_whitelist(whitelist);
303-
}
304-
self.place_storage(WARMUP_KEY.to_vec(), Some(vec![0u8; 32]));
305-
self.place_storage(WARMUP_KEY.to_vec(), None);
306293
}
307294

308295
/// Get the read/write count.

substrate/utils/frame/omni-bencher/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ workspace = true
1515
clap = { features = ["derive"], workspace = true }
1616
cumulus-primitives-proof-size-hostfunction = { workspace = true, default-features = true }
1717
frame-benchmarking-cli = { workspace = true }
18+
polkadot-jemalloc-shim = { workspace = true }
1819
sc-cli = { workspace = true, default-features = true }
1920
sp-runtime = { workspace = true, default-features = true }
2021
sp-statement-store = { workspace = true, default-features = true }
2122
tracing-subscriber = { workspace = true }
2223

24+
[target.'cfg(target_os = "linux")'.dependencies]
25+
# Jemalloc as global allocator prevents huge benchmark regression for storage-heavy extrinsics.
26+
polkadot-jemalloc-shim = { workspace = true, features = ["jemalloc-allocator"] }
27+
2328
[dev-dependencies]
2429
assert_cmd = { workspace = true }
2530
cumulus-test-runtime = { workspace = true }

0 commit comments

Comments
 (0)