Skip to content

Commit 6478406

Browse files
authored
Merge pull request #725 from Veykril/veykril/push-plmkuomkutky
Use jemalloc in benches with decay disabled
2 parents 69d8690 + b195eb6 commit 6478406

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ rustversion = "1.0"
5050
test-log = { version = "0.2.11", features = ["trace"] }
5151
trybuild = "1.0"
5252

53+
[target.'cfg(all(not(target_os = "windows"), not(target_os = "openbsd"), any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "powerpc64")))'.dev-dependencies]
54+
tikv-jemallocator = "0.6.0"
55+
5356
[[bench]]
5457
name = "compare"
5558
harness = false

benches/accumulator.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use std::hint::black_box;
33
use codspeed_criterion_compat::{criterion_group, criterion_main, BatchSize, Criterion};
44
use salsa::Accumulator;
55

6+
include!("shims/global_alloc_overwrite.rs");
7+
68
#[salsa::input]
79
struct Input {
810
expressions: usize,

benches/compare.rs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use codspeed_criterion_compat::{
66
};
77
use salsa::Setter;
88

9+
include!("shims/global_alloc_overwrite.rs");
10+
911
#[salsa::input]
1012
pub struct Input {
1113
#[return_ref]

benches/incremental.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use std::hint::black_box;
33
use codspeed_criterion_compat::{criterion_group, criterion_main, BatchSize, Criterion};
44
use salsa::Setter;
55

6+
include!("shims/global_alloc_overwrite.rs");
7+
68
#[salsa::input]
79
struct Input {
810
field: usize,
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#[cfg(all(
2+
not(target_os = "windows"),
3+
not(target_os = "openbsd"),
4+
any(
5+
target_arch = "x86_64",
6+
target_arch = "aarch64",
7+
target_arch = "powerpc64"
8+
)
9+
))]
10+
#[global_allocator]
11+
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
12+
13+
// Disable decay after 10s because it can show up as *random* slow allocations
14+
// in benchmarks. We don't need purging in benchmarks because it isn't important
15+
// to give unallocated pages back to the OS.
16+
// https://jemalloc.net/jemalloc.3.html#opt.dirty_decay_ms
17+
#[cfg(all(
18+
not(target_os = "windows"),
19+
not(target_os = "openbsd"),
20+
any(
21+
target_arch = "x86_64",
22+
target_arch = "aarch64",
23+
target_arch = "powerpc64"
24+
)
25+
))]
26+
#[allow(non_upper_case_globals)]
27+
#[export_name = "_rjem_malloc_conf"]
28+
#[allow(unsafe_code)]
29+
pub static _rjem_malloc_conf: &[u8] = b"dirty_decay_ms:-1,muzzy_decay_ms:-1\0";

0 commit comments

Comments
 (0)