From 290445e3adce87ff51683d4bd0ad4a0701892bbe Mon Sep 17 00:00:00 2001 From: bonamin Date: Thu, 15 Oct 2026 22:27:31 +0300 Subject: [PATCH] perf(Telemetry): defer play/stop SD writes off the command path (F-075, v2.4.1) recordPlayback() and saveStrikeCounters() wrote JSON to SD inline in the async_tcp task, before playback.play/stop could send their reply. They now set a pending flag and notify TelemetryTask, which writes within ms. The task's periodic work keeps its 1 s cadence (checkBellLoads decays per call); pending writes are held during the OTA pause. Verified on hardware: the reply now goes out before the SD write. Co-Authored-By: Claude Opus 5.5 --- docs/features/feature-catalog.md | 17 +++++++++++++++++ src/Telemetry/Telemetry.cpp | Bin 27043 -> 28483 bytes src/Telemetry/Telemetry.hpp | 12 +++++++++++- src/Version.hpp | 3 ++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/features/feature-catalog.md b/docs/features/feature-catalog.md index 51298a2..b003c6a 100644 --- a/docs/features/feature-catalog.md +++ b/docs/features/feature-catalog.md @@ -87,6 +87,7 @@ Check `git log -- src/Version.hpp` for the real bump history before tagging a ne | F-072 | Lower status/reply latency — QoS 0 for non-critical MQTT topics; WiFi modem sleep disabled | v2.4.0 | Stable | | F-073 | Confirmed delivery for `status/playback` + `control/reports` (QoS 1, PUBACK tracked, reset + republish/resend); AsyncMqttClient vendored + patched; all dependencies pinned | v2.4.0 | Stable | | F-074 | Fix: `mode: "infinite"` no longer flips status playing/paused every ~0.5 s | v2.4.0 | Stable | +| F-075 | Play/stop command replies no longer wait for telemetry SD writes (deferred to TelemetryTask) | v2.4.1 | Stable | --- @@ -1549,3 +1550,19 @@ checked `continuous_loop`, so with a 0 ms segment every duration-timer tick paus rejects `duration: 0`, so no valid segmented mode is affected. Subsystem: `src/Player/Player.cpp` + +### F-075 — Telemetry SD writes deferred off the command path + +**Symptom.** Measured on hardware (2026-10-15): the `playback.play`/`playback.stop` reply arrived 50–100 ms +after the status broadcast even with serial logging off. Between the two, the command handler wrote to the SD +card: `Telemetry::recordPlayback()` (play → `/telemetry_runtime.json`) and `saveStrikeCounters()` (stop → +`/telemetry_data.json`), both inline in the async_tcp task that also has to send the reply. + +**Change.** Both now set a pending flag and notify `TelemetryTask`, which does the write within milliseconds +(`processPendingSaves()`). The task waits on a notification instead of a plain 1 s delay, but the periodic +work keeps its 1 s cadence, since `checkBellLoads()` decays bell loads once per call. Pending writes are +held while telemetry is paused for OTA and done right after `resume()`. Before the task exists (early boot) +`saveStrikeCounters()` still writes synchronously. Repeated requests before the write happens collapse into +one write of the latest values. + +Subsystem: `src/Telemetry/Telemetry.hpp`, `src/Telemetry/Telemetry.cpp` diff --git a/src/Telemetry/Telemetry.cpp b/src/Telemetry/Telemetry.cpp index d16705da53d02b5c13cd33e77df96caf2885173a..7df6a6c8c5e2febf72e65b2461dfeb33e8b64854 100644 GIT binary patch delta 1485 zcma)6J#Q015LHBjEDAsh3Q#bJ=1#I52ZR8dBnk;}5adJH&>^$Ao6D_keP`|N#h73n z6%8Hc49J!f?lnmdtK&8wKe=Coj=SAxHFsOh2kQ?TR+hr10&>b41-4PkUTKB2 za8Ri|3|(qi!{}pb&7X1)thy0lsv5YPlC!~yLe0Y%$IPY_%mf_1sXaY4Z|d(C`h|jF zzr{jVU`r2L#j)v*h$UfG zzPV~CEqQ=O%#p5>ewn@{zj);82?0|gjTB`)ibGzIo2uHGS6fKO~^G5L7g9>8zlA9&P)#f+wOE-YP0odv4PS|YI1H5HCWlw e+m9k`556v5IX~@|!PT8hgYxrh!?({C&iny&Y2oGo delta 98 zcmX?nk8$y3#tk*rlUr4;P?>#_z+KL?_do> y0|Nt1&B^DuzHL73Jc*IJII%3%H?^cFGr4&30txZW+HNbPC+|r$-K?D~!2