-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: auto heap dump by default if MALLOC_CONF=prof:true
#12186
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,7 +370,7 @@ pub struct ServerConfig { | |
pub unrecognized: Unrecognized<Self>, | ||
|
||
/// Enable heap profile dump when memory usage is high. | ||
#[serde(default = "default::server::auto_dump_heap_profile")] | ||
#[serde(default)] | ||
pub auto_dump_heap_profile: AutoDumpHeapProfileConfig, | ||
} | ||
|
||
|
@@ -658,18 +658,19 @@ impl AsyncStackTraceOption { | |
|
||
#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde)] | ||
pub struct AutoDumpHeapProfileConfig { | ||
/// Enable to auto dump heap profile when memory usage is high | ||
#[serde(default = "default::auto_dump_heap_profile::enabled")] | ||
pub enabled: bool, | ||
|
||
/// The directory to dump heap profile. If empty, the prefix in `MALLOC_CONF` will be used | ||
#[serde(default = "default::auto_dump_heap_profile::dir")] | ||
pub dir: String, | ||
|
||
/// The proportion (number between 0 and 1) of memory usage to trigger heap profile dump | ||
#[serde(default = "default::auto_dump_heap_profile::threshold")] | ||
pub threshold: f32, | ||
} | ||
|
||
impl AutoDumpHeapProfileConfig { | ||
pub fn enabled(&self) -> bool { | ||
!self.dir.is_empty() | ||
} | ||
} | ||
|
||
serde_with::with_prefix!(streaming_prefix "stream_"); | ||
serde_with::with_prefix!(batch_prefix "batch_"); | ||
|
||
|
@@ -908,7 +909,7 @@ pub mod default { | |
} | ||
|
||
pub mod server { | ||
use crate::config::{AutoDumpHeapProfileConfig, MetricLevel}; | ||
use crate::config::MetricLevel; | ||
|
||
pub fn heartbeat_interval_ms() -> u32 { | ||
1000 | ||
|
@@ -925,10 +926,6 @@ pub mod default { | |
pub fn telemetry_enabled() -> bool { | ||
true | ||
} | ||
|
||
pub fn auto_dump_heap_profile() -> AutoDumpHeapProfileConfig { | ||
Default::default() | ||
} | ||
} | ||
|
||
pub mod storage { | ||
|
@@ -1130,6 +1127,10 @@ pub mod default { | |
} | ||
|
||
pub mod auto_dump_heap_profile { | ||
pub fn enabled() -> bool { | ||
true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where will we read the env var There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It's actually read from Note that the auto-dump is enabled by default, but if |
||
} | ||
|
||
pub fn dir() -> String { | ||
"".to_string() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,15 +74,8 @@ pub fn build_memory_control_policy( | |
total_memory_bytes: usize, | ||
auto_dump_heap_profile_config: AutoDumpHeapProfileConfig, | ||
) -> Result<MemoryControlRef> { | ||
use risingwave_common::bail; | ||
use tikv_jemalloc_ctl::opt; | ||
|
||
use self::policy::JemallocMemoryControl; | ||
|
||
if !opt::prof::read().unwrap() && auto_dump_heap_profile_config.enabled() { | ||
bail!("Auto heap profile dump should not be enabled with Jemalloc profile disable"); | ||
} | ||
|
||
Ok(Box::new(JemallocMemoryControl::new( | ||
total_memory_bytes, | ||
auto_dump_heap_profile_config, | ||
|
@@ -122,6 +115,14 @@ impl MemoryControl for DummyPolicy { | |
/// overhead, network buffer, etc. based on `SYSTEM_RESERVED_MEMORY_PROPORTION`. The reserve memory | ||
/// size must be larger than `MIN_SYSTEM_RESERVED_MEMORY_MB` | ||
pub fn reserve_memory_bytes(total_memory_bytes: usize) -> (usize, usize) { | ||
if total_memory_bytes < MIN_COMPUTE_MEMORY_MB << 20 { | ||
panic!( | ||
"The total memory size ({}) is too small. It must be at least {} MB.", | ||
convert(total_memory_bytes as _), | ||
MIN_COMPUTE_MEMORY_MB | ||
); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't know why |
||
|
||
let reserved = std::cmp::max( | ||
(total_memory_bytes as f64 * SYSTEM_RESERVED_MEMORY_PROPORTION).ceil() as usize, | ||
MIN_SYSTEM_RESERVED_MEMORY_MB << 20, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about making it a workspace dependency?
risingwave/Cargo.toml
Line 62 in 8841892
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us do it in future PRs. cc. @yuhao-su