Skip to content

Commit

Permalink
Disable trimmer
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Apr 13, 2021
1 parent e72f097 commit 4bda1a7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions common/malloc_utils/src/glibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ use std::result::Result;
use std::thread;
use std::time::Duration;

/// If true, periodically call `malloc_trim`.
const START_TRIMMER: bool = false;

/// The value to be provided to `malloc_trim`.
///
/// Value sourced from:
///
/// - https://man7.org/linux/man-pages/man3/mallopt.3.html
const OPTIMAL_TRIM: c_ulong = 1_024 * 128;

/// The default interval between calls to `spawn_trimmer_thread`.
const OPTIMAL_TRIM_INTERVAL: Duration = Duration::from_secs(60 * 5);

/// The value to be provided to `malloc_mmap_threshold`.
///
/// Value chosen so that it will store the values of the validators tree hash cache.
Expand All @@ -36,9 +42,6 @@ const OPTIMAL_ARENA_MAX: c_int = 1;
const M_MMAP_THRESHOLD: c_int = -4;
const M_ARENA_MAX: c_int = -8;

/// The default interval between calls to `spawn_trimmer_thread`.
const OPTIMAL_TRIM_INTERVAL: Duration = Duration::from_secs(60 * 5);

/// Environment variables used to configure malloc.
///
/// Source:
Expand Down Expand Up @@ -126,7 +129,10 @@ pub fn configure_glibc_malloc() -> Result<(), String> {
}
}

*TRIMMER_THREAD_HANDLE.lock() = Some(spawn_trimmer_thread(OPTIMAL_TRIM_INTERVAL, OPTIMAL_TRIM));
if START_TRIMMER {
*TRIMMER_THREAD_HANDLE.lock() =
Some(spawn_trimmer_thread(OPTIMAL_TRIM_INTERVAL, OPTIMAL_TRIM));
}

Ok(())
}
Expand Down

0 comments on commit 4bda1a7

Please sign in to comment.