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/http_api.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'main/http_api.c') diff --git a/main/http_api.c b/main/http_api.c index 238514b..ccd795b 100644 --- a/main/http_api.c +++ b/main/http_api.c @@ -101,6 +101,17 @@ static esp_err_t state_get_handler(httpd_req_t *req) cJSON_AddNumberToObject(s, "idle_min_us", (double)stream.idle_min_us); cJSON_AddNumberToObject(s, "idle_avg_us", (double)stream.idle_avg_us); cJSON_AddNumberToObject(s, "idle_max_us", (double)stream.idle_max_us); + // Recv-throughput diagnostics. See stream_server.h for semantics. + cJSON_AddNumberToObject(s, "queued_min", (double)stream.queued_min); + cJSON_AddNumberToObject(s, "queued_avg", (double)stream.queued_avg); + cJSON_AddNumberToObject(s, "queued_max", (double)stream.queued_max); + cJSON_AddNumberToObject(s, "recv_calls_min", (double)stream.recv_calls_min); + cJSON_AddNumberToObject(s, "recv_calls_avg", (double)stream.recv_calls_avg); + cJSON_AddNumberToObject(s, "recv_calls_max", (double)stream.recv_calls_max); + cJSON_AddNumberToObject(s, "recv_chunk_min", (double)stream.recv_chunk_min); + cJSON_AddNumberToObject(s, "recv_chunk_avg", (double)stream.recv_chunk_avg); + cJSON_AddNumberToObject(s, "recv_chunk_max", (double)stream.recv_chunk_max); + cJSON_AddNumberToObject(s, "so_rcvbuf", (double)stream.so_rcvbuf); cJSON_AddNumberToObject(s, "last_paint_event_us_low", (double)stream.last_paint_event_us_low); cJSON_AddItemToObject(root, "stream", s); -- cgit v1.2.3