Skip to content

Commit

Permalink
Merge pull request #725 from Veykril/veykril/push-plmkuomkutky
Browse files Browse the repository at this point in the history
Use jemalloc in benches with decay disabled
  • Loading branch information
Veykril authored Feb 24, 2025
2 parents 69d8690 + b195eb6 commit 6478406
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ rustversion = "1.0"
test-log = { version = "0.2.11", features = ["trace"] }
trybuild = "1.0"

[target.'cfg(all(not(target_os = "windows"), not(target_os = "openbsd"), any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "powerpc64")))'.dev-dependencies]
tikv-jemallocator = "0.6.0"

[[bench]]
name = "compare"
harness = false
Expand Down
2 changes: 2 additions & 0 deletions benches/accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::hint::black_box;
use codspeed_criterion_compat::{criterion_group, criterion_main, BatchSize, Criterion};
use salsa::Accumulator;

include!("shims/global_alloc_overwrite.rs");

#[salsa::input]
struct Input {
expressions: usize,
Expand Down
2 changes: 2 additions & 0 deletions benches/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use codspeed_criterion_compat::{
};
use salsa::Setter;

include!("shims/global_alloc_overwrite.rs");

#[salsa::input]
pub struct Input {
#[return_ref]
Expand Down
2 changes: 2 additions & 0 deletions benches/incremental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::hint::black_box;
use codspeed_criterion_compat::{criterion_group, criterion_main, BatchSize, Criterion};
use salsa::Setter;

include!("shims/global_alloc_overwrite.rs");

#[salsa::input]
struct Input {
field: usize,
Expand Down
29 changes: 29 additions & 0 deletions benches/shims/global_alloc_overwrite.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#[cfg(all(
not(target_os = "windows"),
not(target_os = "openbsd"),
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64"
)
))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

// Disable decay after 10s because it can show up as *random* slow allocations
// in benchmarks. We don't need purging in benchmarks because it isn't important
// to give unallocated pages back to the OS.
// https://jemalloc.net/jemalloc.3.html#opt.dirty_decay_ms
#[cfg(all(
not(target_os = "windows"),
not(target_os = "openbsd"),
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64"
)
))]
#[allow(non_upper_case_globals)]
#[export_name = "_rjem_malloc_conf"]
#[allow(unsafe_code)]
pub static _rjem_malloc_conf: &[u8] = b"dirty_decay_ms:-1,muzzy_decay_ms:-1\0";

0 comments on commit 6478406

Please sign in to comment.