From aa50d918376f6165d497bbdb9e9d0ff4b7eafa15 Mon Sep 17 00:00:00 2001 From: janost Date: Thu, 19 Mar 2026 16:50:04 +0100 Subject: [PATCH] =?UTF-8?q?chore(rtsp):=20tune=20buffer=20pool=20=E2=80=94?= =?UTF-8?q?=20bump=20MAX=5FBUCKET=20to=204MB,=20add=20diagnostics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Increase MAX_BUCKET from 1MB to 4MB so 4K camera keyframes stay within the pooled allocation path. Add trace logging for bucket distribution and debug logging when frames exceed MAX_BUCKET and fall back to non-pooled allocation. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/rtsp/factory.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rtsp/factory.rs b/src/rtsp/factory.rs index 98d0190f..eb289351 100644 --- a/src/rtsp/factory.rs +++ b/src/rtsp/factory.rs @@ -434,7 +434,7 @@ fn send_to_sources( fn bucket_size_for(n: usize) -> Option { const MIN_BUCKET: usize = 256; - const MAX_BUCKET: usize = 1024 * 1024; + const MAX_BUCKET: usize = 4 * 1024 * 1024; if n == 0 { return Some(MIN_BUCKET); } @@ -465,6 +465,7 @@ fn acquire_pooled_buffer( pool }); + log::trace!("Pooled buffer: needed={needed}, bucket={bucket}"); let mut buf = pool.acquire_buffer(None)?; { let buf_ref = buf.get_mut().unwrap(); @@ -480,6 +481,7 @@ fn acquire_pooled_buffer( } Ok(buf) } else { + log::debug!("Frame size {needed} exceeds MAX_BUCKET, falling back to non-pooled allocation"); let mut buf = gstreamer::Buffer::with_size(needed) .context("allocate large non-pooled buffer")?; {