mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-06 21:12:55 +00:00
pageserver,safekeeper: increase heap profiling frequency to 2 MB (#10362)
## Problem Currently, the heap profiling frequency is every 1 MB allocated. Taking a profile stack trace takes about 1 µs, and allocating 1 MB takes about 15 µs, so the overhead is about 6.7% which is a bit high. This is a fixed cost regardless of whether heap profiles are actually accessed. ## Summary of changes Increase the heap profiling sample frequency from 1 MB to 2 MB, which reduces the overhead to about 3.3%. This seems acceptable, considering performance-sensitive code will avoid allocations as far as possible anyway.
This commit is contained in:
@@ -53,10 +53,12 @@ project_build_tag!(BUILD_TAG);
|
|||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||||
|
|
||||||
/// Configure jemalloc to sample allocations for profiles every 1 MB (1 << 20).
|
/// Configure jemalloc to profile heap allocations by sampling stack traces every 2 MB (1 << 21).
|
||||||
|
/// This adds roughly 3% overhead for allocations on average, which is acceptable considering
|
||||||
|
/// performance-sensitive code will avoid allocations as far as possible anyway.
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
#[export_name = "malloc_conf"]
|
#[export_name = "malloc_conf"]
|
||||||
pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:20\0";
|
pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:21\0";
|
||||||
|
|
||||||
const PID_FILE_NAME: &str = "pageserver.pid";
|
const PID_FILE_NAME: &str = "pageserver.pid";
|
||||||
|
|
||||||
|
|||||||
@@ -21,14 +21,13 @@ const KB: usize = 1024;
|
|||||||
const MB: usize = 1024 * KB;
|
const MB: usize = 1024 * KB;
|
||||||
const GB: usize = 1024 * MB;
|
const GB: usize = 1024 * MB;
|
||||||
|
|
||||||
/// Use jemalloc, and configure it to sample allocations for profiles every 1 MB.
|
/// Use jemalloc and enable profiling, to mirror bin/safekeeper.rs.
|
||||||
/// This mirrors the configuration in bin/safekeeper.rs.
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
#[export_name = "malloc_conf"]
|
#[export_name = "malloc_conf"]
|
||||||
pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:20\0";
|
pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:21\0";
|
||||||
|
|
||||||
// Register benchmarks with Criterion.
|
// Register benchmarks with Criterion.
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
|
|||||||
@@ -51,10 +51,12 @@ use utils::{
|
|||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||||
|
|
||||||
/// Configure jemalloc to sample allocations for profiles every 1 MB (1 << 20).
|
/// Configure jemalloc to profile heap allocations by sampling stack traces every 2 MB (1 << 21).
|
||||||
|
/// This adds roughly 3% overhead for allocations on average, which is acceptable considering
|
||||||
|
/// performance-sensitive code will avoid allocations as far as possible anyway.
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
#[export_name = "malloc_conf"]
|
#[export_name = "malloc_conf"]
|
||||||
pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:20\0";
|
pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:21\0";
|
||||||
|
|
||||||
const PID_FILE_NAME: &str = "safekeeper.pid";
|
const PID_FILE_NAME: &str = "safekeeper.pid";
|
||||||
const ID_FILE_NAME: &str = "safekeeper.id";
|
const ID_FILE_NAME: &str = "safekeeper.id";
|
||||||
|
|||||||
Reference in New Issue
Block a user