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 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 22:27:31 +03:00
co-authored by Claude Opus 5.5
parent b121560b1f
commit 290445e3ad
4 changed files with 30 additions and 2 deletions
+17
View File
@@ -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`