Skip to content

Commit

Permalink
feat(heap_profiling): enable heap profiling for meta node. (#12737)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhao-su authored Oct 11, 2023
1 parent ac2a58c commit bf0d05f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ use std::time::Duration;
use clap::Parser;
pub use error::{MetaError, MetaResult};
use risingwave_common::config::OverrideConfig;
use risingwave_common::heap_profiling::HeapProfiler;
use risingwave_common::util::resource_util;
use risingwave_common::{GIT_SHA, RW_VERSION};
pub use rpc::{ElectionClient, ElectionMember, EtcdElectionClient};

Expand Down Expand Up @@ -191,6 +193,11 @@ pub struct MetaNodeOpts {
#[clap(long, env = "RW_OBJECT_STORE_READ_TIMEOUT_MS", value_enum)]
#[override_opts(path = storage.object_store_read_timeout_ms)]
pub object_store_read_timeout_ms: Option<u64>,

/// Enable heap profile dump when memory usage is high.
#[clap(long, env = "RW_HEAP_PROFILING_DIR")]
#[override_opts(path = server.heap_profiling.dir)]
pub heap_profiling_dir: Option<String>,
}

use std::future::Future;
Expand Down Expand Up @@ -232,6 +239,12 @@ pub fn start(opts: MetaNodeOpts) -> Pin<Box<dyn Future<Output = ()> + Send>> {

validate_config(&config);

let total_memory_bytes = resource_util::memory::total_memory_available_bytes();
let heap_profiler =
HeapProfiler::new(total_memory_bytes, config.server.heap_profiling.clone());
// Run a background heap profiler
heap_profiler.start();

let max_heartbeat_interval =
Duration::from_secs(config.meta.max_heartbeat_interval_secs as u64);
let max_idle_ms = config.meta.dangerous_max_idle_secs.unwrap_or(0) * 1000;
Expand Down

0 comments on commit bf0d05f

Please sign in to comment.