Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pgdog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ libc = "0.2"

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = "0.6"
tikv-jemalloc-ctl = "0.6"


[build-dependencies]
Expand Down
11 changes: 11 additions & 0 deletions pgdog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
#[global_allocator]
static GLOBAL: &stats_alloc::StatsAlloc<System> = &stats_alloc::INSTRUMENTED_SYSTEM;

/// Enable jemalloc's background purge threads so freed memory is returned to
/// the OS after allocation bursts.
#[cfg(all(not(test), not(target_env = "msvc")))]
pub fn enable_jemalloc_background_thread() {
let _ = tikv_jemalloc_ctl::background_thread::write(true);
}

/// No-op fallback where jemalloc is not the active allocator.
#[cfg(any(test, target_env = "msvc"))]
pub fn enable_jemalloc_background_thread() {}

/// Filter that dynamically installs or removes an inner
/// [`TracingRateLimitLayer`] at runtime.
///
Expand Down
2 changes: 2 additions & 0 deletions pgdog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use tokio::runtime::Builder;
use tracing::{error, info, warn};

fn main() -> Result<(), Box<dyn std::error::Error>> {
pgdog::enable_jemalloc_background_thread();

let args = cli::Cli::parse();
let command = args.command.clone();
let mut overrides = pgdog::config::Overrides::default();
Expand Down
Loading