fix(runtime): raise debug worker stack headroom

Co-Authored-By: heihutu <heihutu@gmail.com>
This commit is contained in:
houseme
2026-07-24 00:54:00 +08:00
parent 7aa2b56a36
commit 966f1f7beb
+25 -3
View File
@@ -19,15 +19,37 @@ use rustfs_obs::dial9::Dial9SessionGuard;
#[inline]
fn compute_default_thread_stack_size() -> usize {
// Baseline: Release 1 MiBDebug 2 MiBmacOS at least 2 MiB
// macOS is more conservative: many system libraries and backtracking are more "stack-eating"
if cfg!(debug_assertions) || cfg!(target_os = "macos") {
if cfg!(debug_assertions) {
// Debug builds keep larger async futures and tracing state on the stack;
// scanner e2e paths need more headroom than the release runtime.
8 * rustfs_config::DEFAULT_THREAD_STACK_SIZE
} else if cfg!(target_os = "macos") {
// macOS is more conservative: many system libraries and backtracking are more "stack-eating"
2 * rustfs_config::DEFAULT_THREAD_STACK_SIZE
} else {
rustfs_config::DEFAULT_THREAD_STACK_SIZE
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_thread_stack_size_matches_build_profile() {
let default_stack = rustfs_config::DEFAULT_THREAD_STACK_SIZE;
let expected = if cfg!(debug_assertions) {
8 * default_stack
} else if cfg!(target_os = "macos") {
2 * default_stack
} else {
default_stack
};
assert_eq!(compute_default_thread_stack_size(), expected);
}
}
#[inline]
fn detect_cores() -> usize {
// Priority physical cores, fallback logic cores, minimum 1