From 36c420c872a2afc8cb60d5487cb28fbcbbcdc230 Mon Sep 17 00:00:00 2001 From: ChuckBuilds Date: Fri, 21 Aug 2026 10:27:48 -0400 Subject: [PATCH] fix(vegas): use a monotonic clock for the frame-rate timers Self-review catch. The heartbeat added in this PR compared wall-clock timestamps, which is the defect CodeRabbit flagged on the metrics throttle and which I had already fixed there: these devices have no RTC, so the clock jumps by however wrong boot time was when NTP first syncs. A backward jump would suppress the heartbeat, a forward one fire it early. The same value also divides the frame count to produce the frame rate, so a jump corrupted the reported fps as well -- a pre-existing problem this makes worth fixing rather than working around. last_fps_log_time was seeded from start_time, which is wall clock and is used further down to report the iteration duration. Switching only the reads would have made every delta hugely negative and silenced frame-rate reporting completely, so the seed moves to time.monotonic() and start_time is left alone for the duration reporting it exists for. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01STMbQE4YctTacQXfbYqKuW --- assets/sports/ncaa_logos/COR.png | Bin 0 -> 467 bytes src/vegas_mode/coordinator.py | 13 +++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 assets/sports/ncaa_logos/COR.png diff --git a/assets/sports/ncaa_logos/COR.png b/assets/sports/ncaa_logos/COR.png new file mode 100644 index 0000000000000000000000000000000000000000..d39027fabec5bf8b8f20c6457c51ab79677ac05e GIT binary patch literal 467 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEV4UUY;uumf=k2wFzK0D&*dExg zU{`Tt=plM2Td_4i_7_blh45g z2^>AtseG|%*FuA55r1Z1zS5!D+{P9gO)Ty?#@ZL+@hiv2d*nLSI{p8U_qd0^eZ%P`~Stut{+ANdYssT?ty_nl!Lcihe+ zJjMSeX&P)fw=Orp%#7jrE#|+C=Vh{*8`otT7!=lqz3VFM z=gv(^`{`6Ur^@tQmi(DkfuQC%#yv|z?RVR!$@ec0{y2Nt%eO4&cCK7mu=^oiV+Am>7(8A5T-G@yGywp) CdCl1X literal 0 HcmV?d00001 diff --git a/src/vegas_mode/coordinator.py b/src/vegas_mode/coordinator.py index 92980ef3..ecd59529 100644 --- a/src/vegas_mode/coordinator.py +++ b/src/vegas_mode/coordinator.py @@ -406,7 +406,11 @@ class VegasModeCoordinator: fps_log_interval = 5.0 # Sample FPS every 5 seconds last_fps_health_log = 0.0 # last INFO-level report was_degraded = False # so the recovery is reported too - last_fps_log_time = start_time + # Monotonic, and deliberately not start_time: start_time is wall + # clock and is used below to report the iteration's duration. Mixing + # the two here would make every delta hugely negative and silence the + # frame-rate reporting altogether. + last_fps_log_time = time.monotonic() fps_frame_count = 0 # A mean hides stutter completely. At 120fps a five-second window is # ~600 frames, so a 200ms freeze -- plainly visible on a marquee -- @@ -467,7 +471,12 @@ class VegasModeCoordinator: # of them within 10% of target. The 1.5% that were not included a # reading of 8.6fps against a target of 60 -- a real stall, and # completely invisible inside 1389 lines reading "59.6". - current_time = time.time() + # Monotonic: every use of this value in the block below is a + # duration, and these devices have no RTC, so the wall clock jumps + # by however wrong boot time was the moment NTP first syncs. That + # would not only mis-fire the heartbeat, it would corrupt the + # frame rate itself, since fps is frames divided by this delta. + current_time = time.monotonic() if current_time - last_fps_log_time >= fps_log_interval: fps = fps_frame_count / (current_time - last_fps_log_time) p99 = _percentile(sorted(frame_times), 0.99)