This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-23648-run-folder in repository https://gitbox.apache.org/repos/asf/camel.git
commit 60abf2b6e2528810fb20083477e5e6a38be71013 Author: Claus Ibsen <[email protected]> AuthorDate: Mon Jun 1 10:35:15 2026 +0200 CAMEL-23648: camel-jbang - TUI throttle full PID scan and instant log load Throttle the full ProcessHandle.allProcesses() scan to every 2 seconds on the Overview tab instead of every 100ms tick. Between scans, reuse cached PIDs with fast status-only refreshes. Also load log data directly from the tick handler when a full refresh is in progress, so the Log tab appears instantly when switching from Overview instead of waiting 3-4s. Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../camel/dsl/jbang/core/commands/tui/CamelMonitor.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java index 036e6dec3bfa..fb6aa2caf850 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java @@ -197,8 +197,9 @@ public class CamelMonitor extends CamelCommand { private final Map<String, LoadAvg> cpuLoadAvg = new ConcurrentHashMap<>(); private final Map<String, long[]> prevCpuSample = new ConcurrentHashMap<>(); - // Cached PID list — full process scan only on Overview tab or F3 switch popup + // Cached PID list — full process scan throttled to every 2 seconds private volatile List<Long> cachedPids = Collections.emptyList(); + private volatile long lastFullScanTime; // Trace/history data — shared between CamelMonitor and tabs private final AtomicReference<List<TraceEntry>> traces = new AtomicReference<>(Collections.emptyList()); @@ -778,6 +779,11 @@ public class CamelMonitor extends CamelCommand { long cutoff = now - 2000; recentKeys.removeIf(k -> k.timestamp() < cutoff); } + // If log tab is loading but a full refresh is already in progress, + // read log data directly so it appears without waiting for the PID scan + if (tabsState.selected() == TAB_LOG && logTab.logLoading && refreshInProgress.get()) { + refreshLogData(); + } long interval = routesTab.isShowDiagram() ? Math.max(refreshInterval, 1000) : refreshInterval; if (now - lastRefresh >= interval) { refreshData(); @@ -1790,11 +1796,14 @@ public class CamelMonitor extends CamelCommand { refreshLogData(); List<IntegrationInfo> infos = new ArrayList<>(); - boolean fullScan = tabsState.selected() == TAB_OVERVIEW || showSwitchPopup || cachedPids.isEmpty(); + long now = System.currentTimeMillis(); + boolean wantFullScan = tabsState.selected() == TAB_OVERVIEW || showSwitchPopup || cachedPids.isEmpty(); + boolean fullScan = wantFullScan && (now - lastFullScanTime >= 2000); List<Long> pids; if (fullScan) { pids = findPids(name); cachedPids = pids; + lastFullScanTime = now; } else { pids = cachedPids; } @@ -1848,7 +1857,6 @@ public class CamelMonitor extends CamelCommand { } // Expire old vanishing entries - long now = System.currentTimeMillis(); Iterator<Map.Entry<String, VanishingInfo>> it = vanishing.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, VanishingInfo> entry = it.next();
