From 4673dd6d295029016e5a7fa7fcedac93e14402dc Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Thu, 3 Oct 2024 14:54:10 +0100 Subject: [PATCH] set thp:never during build --- Dockerfile | 1 + proxy/src/bin/proxy.rs | 2 +- proxy/src/jemalloc.rs | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index bdb76a4f4f..eeb5864cb6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,7 @@ COPY --from=pg-build /home/nonroot/pg_install/v17/lib pg_i COPY --chown=nonroot . . ARG ADDITIONAL_RUSTFLAGS +ENV _RJEM_MALLOC_CONF="thp:never" RUN set -e \ && PQ_LIB_DIR=$(pwd)/pg_install/v${STABLE_PG_VERSION}/lib RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=mold -Clink-arg=-Wl,--no-rosegment ${ADDITIONAL_RUSTFLAGS}" cargo build \ --bin pg_sni_router \ diff --git a/proxy/src/bin/proxy.rs b/proxy/src/bin/proxy.rs index a555c3e586..90fc3de56d 100644 --- a/proxy/src/bin/proxy.rs +++ b/proxy/src/bin/proxy.rs @@ -297,7 +297,7 @@ async fn main() -> anyhow::Result<()> { build_tag: BUILD_TAG, }); - proxy::jemalloc::disable_thp()?; + proxy::jemalloc::inspect_thp()?; let jemalloc = match proxy::jemalloc::MetricRecorder::new() { Ok(t) => Some(t), Err(e) => { diff --git a/proxy/src/jemalloc.rs b/proxy/src/jemalloc.rs index 4548caf70b..cb3c4ca42f 100644 --- a/proxy/src/jemalloc.rs +++ b/proxy/src/jemalloc.rs @@ -10,6 +10,7 @@ use measured::{ LabelGroup, MetricGroup, }; use tikv_jemalloc_ctl::{config, epoch, epoch_mib, stats, version, Access, AsName, Name}; +use tracing::info; pub struct MetricRecorder { epoch: epoch_mib, @@ -115,7 +116,9 @@ jemalloc_gauge!(metadata, metadata_mib); jemalloc_gauge!(resident, resident_mib); jemalloc_gauge!(retained, retained_mib); -pub fn disable_thp() -> Result<(), tikv_jemalloc_ctl::Error> { - let opt_thp: &Name = "opt.thp".name(); - opt_thp.write("never") +pub fn inspect_thp() -> Result<(), tikv_jemalloc_ctl::Error> { + let opt_thp: &Name = c"opt.thp".to_bytes_with_nul().name(); + let s: &str = opt_thp.read()?; + info!("jemalloc opt.thp {s}"); + Ok(()) }