git.lucas.co / cce-window-manager
window management library
git clone https://git.lucas.co/cce-window-manager.git

commit881aebd417a45875aeccfcdf73ef9f6063a233bb
parent2c1010add3
authorLucas Galante <[email protected]>
date2026-08-13 00:22
perf: gate status-bar arrange tracing behind CCE_ARRANGE_DEBUG

These three sites were log::info!, so they wrote on every arrange regardless of
log level — and a status-bar commit runs a full arrange every second, so on an
idle desktop they were a steady drip into the session log. Now behind their own
switch (mirroring the mechanism-side one in the compositor) and downgraded to
debug!, so enabling debug logging no longer implies paying for them.

Co-Authored-By: Claude Opus 5 <[email protected]>

 src/arrange.rs | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/arrange.rs b/src/arrange.rs
index c28dabe..e91acf1 100644
--- a/src/arrange.rs
+++ b/src/arrange.rs
@@ -9,6 +9,15 @@
 use super::api::{DecorationSpec, Rect, WindowRole};
 use super::tiling::TilingMode;
 
+/// `CCE_ARRANGE_DEBUG=1` — status-bar placement tracing. These sites were
+/// `info!`, so they wrote on every arrange regardless of log level, and a
+/// status-bar commit runs an arrange every second. Mirrors the mechanism-side
+/// switch of the same name in the compositor's `window_manager.rs`.
+fn arrange_debug() -> bool {
+    static FLAG: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
+    *FLAG.get_or_init(|| std::env::var_os("CCE_ARRANGE_DEBUG").is_some())
+}
+
 /// Which screen edge/region a status-bar window docks to.
 /// Set from the app_id suffix or config; `Unspecified` resolves to `TopLeft`.
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -648,7 +657,9 @@ pub fn layout_status_bars(
         }
     }
 
-    log::info!("[ArrangeStatus] top_left_len={}, top_center_len={}, top_right_len={}, left_side_len={}", top_left.len(), top_center.len(), top_right.len(), left_side.len());
+    if arrange_debug() {
+        log::debug!("[ArrangeStatus] top_left_len={}, top_center_len={}, top_right_len={}, left_side_len={}", top_left.len(), top_center.len(), top_right.len(), left_side.len());
+    }
 
     let sort_left = |list: &mut Vec<usize>| {
         list.sort_by_key(|&i| left_sort_key(&items[i].app_id));
@@ -688,7 +699,9 @@ pub fn layout_status_bars(
         if w as i32 > max_allowed_w {
             w = std::cmp::max(max_allowed_w, 20) as u32;
         }
-        log::info!("[TopLeftLayout] app_id={} x={}, w={}", items[i].app_id, cur_left_x, w);
+        if arrange_debug() {
+            log::debug!("[TopLeftLayout] app_id={} x={}, w={}", items[i].app_id, cur_left_x, w);
+        }
         placements[i] = Some(StatusBarPlacement { x: cur_left_x, y: status_y_top, width: w, height: bar_h, enforce_size: !items[i].expanded });
         cur_left_x += w as i32 + spacing;
     }
@@ -1214,7 +1227,9 @@ pub fn arrange(
                     if w.being_moved {
                         continue;
                     }
-                    log::info!("[ArrangeStatus] app_id={} status_edge={:?}", app_id, w.status_edge);
+                    if arrange_debug() {
+                        log::debug!("[ArrangeStatus] app_id={} status_edge={:?}", app_id, w.status_edge);
+                    }
                     // Thickness = the axis perpendicular to the segment's
                     // edge; a segment thicker than the bar has grown an
                     // in-surface menu (expanded) and keeps its FROZEN