From 19c090566fc15e72508166d81fd42eb46ac8efd5 Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sat, 20 Jun 2026 20:16:01 -0500 Subject: firmware: recv-throughput instrumentation (FIONREAD pre-body, recv() call/chunk stats, SO_RCVBUF probe) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per-frame samples aggregated over the existing 30-frame window: - queued_at_body_start (FIONREAD just before body recv loop): how much of the frame the kernel already absorbed during the previous decode+paint. Close to jpeg_len → wire delivered the full frame while we were busy (we're decode/paint-bound). Much smaller → wire is throttled (window or buffer too small to absorb a frame in our paint window). - recv_calls: number of recv() syscalls the body read needed per frame. High → small chunks → window-throttled sender. - recv_chunk min/avg/max: bytes returned per recv() return in the window. Avg = window body bytes / total syscalls. - SO_RCVBUF: one-shot getsockopt at accept, logged and stashed in stats. Confirms whether sdkconfig values reached the build — TCP_WND_DEFAULT discrepancies are otherwise invisible. All surfaced in the windowed log and in /state JSON alongside the existing recv/dec/paint/idle stats. No behavior change yet. --- main/stream_server.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'main/stream_server.h') diff --git a/main/stream_server.h b/main/stream_server.h index 1d13457..5de1e1f 100644 --- a/main/stream_server.h +++ b/main/stream_server.h @@ -51,6 +51,17 @@ typedef struct { uint32_t dec_min_us, dec_avg_us, dec_max_us; uint32_t pnt_min_us, pnt_avg_us, pnt_max_us; uint32_t idle_min_us, idle_avg_us, idle_max_us; + // Recv-throughput diagnostics. Per-frame samples aggregated over the + // window. queued_at_body_start = FIONREAD just before the body recv + // loop runs; if it's close to jpeg_len the wire delivered the whole + // frame while we were decoding the previous one (we're not the bottleneck). + // recv_calls = number of recv() syscalls the body read needed (high → + // many small chunks → window-throttled sender). recv_chunk = body + // bytes returned per single recv() call within the window. + uint32_t queued_min, queued_avg, queued_max; // bytes + uint32_t recv_calls_min, recv_calls_avg, recv_calls_max; // syscalls per frame body + uint32_t recv_chunk_min, recv_chunk_avg, recv_chunk_max; // bytes per recv() return + uint32_t so_rcvbuf; // SO_RCVBUF observed at accept (0 = unknown) uint32_t last_paint_event_us_low; // last v1 frame's event_us_low, // 0 if none seen yet on this // boot or last frame was v0 -- cgit v1.2.3