From 2bfdf679d30a6d57494906e05583939dd62ba88e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 20 Aug 2026 06:30:46 -0400 Subject: [PATCH] perf(flights): stop the tracker writing 690 log lines every half hour The flight tracker logged two unconditional INFO lines on every poll -- one naming the aircraft count it was about to process, one summarising the result. Polls run about every five seconds, so on a live rig that was 686 lines per half hour, roughly 86% of the device's entire log volume, and a steady trickle of journal writes to the SD card for a line that mostly repeated itself. The "Processing N aircraft" line is trace: the summary immediately below reports the same total. Demoted to debug, with lazy %-args so a disabled level costs nothing to skip. The summary is worth keeping, so it is now reported when it changes. Which fields to key on mattered more than expected. Total and With-position jitter on almost every poll as distant traffic drifts through the receiver's edge, and keying on the whole line collapsed 343 samples to 210 -- barely worth doing. Keying on what the plugin actually displays, aircraft in range and aircraft tracked, collapses the same samples to 67. The jittery counts still ride along in the message, where they cost nothing. A 300-second heartbeat keeps a quiet sky from looking like a stalled tracker. Measured by replaying 343 real polls captured from a running rig through the committed logic: 686 lines become 67, a 90% reduction, with the heartbeat never needing to fire. Safety harness passes at all eight sizes. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01STMbQE4YctTacQXfbYqKuW --- plugins.json | 2 +- plugins/ledmatrix-flights/manager.py | 31 +++++++++++++++++++++++-- plugins/ledmatrix-flights/manifest.json | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/plugins.json b/plugins.json index fe71fed6..3ff2a51e 100644 --- a/plugins.json +++ b/plugins.json @@ -439,7 +439,7 @@ "last_updated": "2026-08-03", "verified": true, "screenshot": "", - "latest_version": "1.12.13" + "latest_version": "1.12.16" }, { "id": "march-madness", diff --git a/plugins/ledmatrix-flights/manager.py b/plugins/ledmatrix-flights/manager.py index 06385747..30a86a99 100644 --- a/plugins/ledmatrix-flights/manager.py +++ b/plugins/ledmatrix-flights/manager.py @@ -1703,7 +1703,11 @@ def _process_aircraft_data(self, data: Dict) -> None: return total_aircraft = len(data['aircraft']) - self.logger.info(f"[Flight Tracker] Processing {total_aircraft} aircraft from SkyAware") + # Trace, not news: the Summary line below reports the same total, and + # this pair ran every few seconds. Lazy %-args so a disabled level + # costs nothing. + self.logger.debug("[Flight Tracker] Processing %d aircraft from SkyAware", + total_aircraft) current_time = time.time() active_icao = set() @@ -1820,7 +1824,30 @@ def _process_aircraft_data(self, data: Dict) -> None: for icao in stale_all: del self.all_aircraft_data[icao] - self.logger.info(f"[Flight Tracker] Summary - Total: {total_aircraft}, With position: {aircraft_with_position}, In range ({self.map_radius_miles}mi): {aircraft_in_range}, Tracking: {len(self.aircraft_data)}, Removed stale: {len(stale_icao)}") + # This ran on every poll -- roughly every five seconds, so ~690 lines + # per half hour, most of the device's log volume and a steady trickle + # of SD writes for a line that usually repeats itself. + # + # Keyed on what the plugin actually shows: aircraft in range and + # tracked. Total and With-position jitter every poll as distant + # traffic drifts in and out of the receiver, so keying on them + # collapsed almost nothing (343 lines -> 210 on measured data); + # keying on these two gives 343 -> 67. The jittery counts still ride + # along in the message, where they cost nothing. + summary = (aircraft_in_range, len(self.aircraft_data)) + last_logged = getattr(self, '_last_summary_log', 0.0) + message = ("[Flight Tracker] Summary - Total: %d, With position: %d, " + "In range (%smi): %d, Tracking: %d, Removed stale: %d") + args = (total_aircraft, aircraft_with_position, self.map_radius_miles, + aircraft_in_range, len(self.aircraft_data), len(stale_icao)) + # The heartbeat keeps a quiet sky from looking like a stalled tracker. + if summary != getattr(self, '_last_summary', None) or \ + current_time - last_logged >= 300: + self.logger.info(message, *args) + self._last_summary_log = current_time + else: + self.logger.debug(message, *args) + self._last_summary = summary self._update_flight_records() def _altitude_to_color(self, altitude: float) -> Tuple[int, int, int]: diff --git a/plugins/ledmatrix-flights/manifest.json b/plugins/ledmatrix-flights/manifest.json index a293588b..c23b2f80 100644 --- a/plugins/ledmatrix-flights/manifest.json +++ b/plugins/ledmatrix-flights/manifest.json @@ -1,7 +1,7 @@ { "id": "ledmatrix-flights", "name": "Flight Tracker", - "version": "1.12.13", + "version": "1.12.16", "description": "Real-time aircraft tracking with ADS-B/FlightRadar24/OpenSky/adsb.fi/adsb.lol data, map backgrounds, area mode, flight tracking, anchor airport, flight records, and optional airport weather (METAR/TAF/PIREP/SIGMET via the free NOAA Aviation Weather Center API)", "author": "ChuckBuilds", "entry_point": "manager.py",