дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 01:31:41 +02:00
fix(logging): shrink the log writer queue from 128000 to 16384 lines (#7211)
tracing-appender's default non-blocking queue holds 128 000 lines and is allocated up front (about 4 MB) for a backlog the writer thread never builds. The log writer uses a 16 384-line queue. Co-authored-by: Pecnikas <[email protected]>
Цей коміт міститься в:
1 file changed
+7
-1
@@ -15,6 +15,8 @@ use tracing_subscriber::{EnvFilter, Layer};
|
||||
|
||||
const PREFIX: &str = "openidea";
|
||||
const SUFFIX: &str = "log";
|
||||
/// Lines waiting for the log writer thread before new ones are dropped.
|
||||
const LOG_QUEUE_LINES: usize = 16_384;
|
||||
|
||||
static LOG_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||
static GUARD: OnceLock<WorkerGuard> = OnceLock::new();
|
||||
@@ -38,7 +40,11 @@ pub fn init(identifier: &str) {
|
||||
.max_log_files(7)
|
||||
.build(&dir)
|
||||
.ok()?;
|
||||
let (writer, guard) = tracing_appender::non_blocking(appender);
|
||||
// The default queue holds 128 000 lines and is filled when it is created: 4 MB of memory for a
|
||||
// backlog the writer thread never builds.
|
||||
let (writer, guard) = tracing_appender::non_blocking::NonBlockingBuilder::default()
|
||||
.buffered_lines_limit(LOG_QUEUE_LINES)
|
||||
.finish(appender);
|
||||
let _ = GUARD.set(guard);
|
||||
log_panics(dir.clone());
|
||||
let _ = LOG_DIR.set(dir);
|
||||
|
||||
Reference in new issue
Заблокувати користувача