Add broker and web throughput diagnostics

This commit is contained in:
2026-09-08 22:40:58 +02:00
parent 36d41be422
commit 042499e4d6
20 changed files with 899 additions and 5 deletions
+38
View File
@@ -135,6 +135,44 @@ esp_err_t web_serial_transport_revoke_web_session(web_session_id_t id);
esp_err_t web_serial_transport_get_snapshot(
web_serial_transport_snapshot_t *snapshot);
typedef struct {
uint64_t count, sum_us, max_us;
} web_serial_performance_timing_t;
typedef struct {
bool active, pending, measured_pending, executing, saturated;
int socket_fd;
uint32_t generation;
session_broker_client_id_t broker_client_id;
uint64_t pending_age_us;
uint64_t queued_frames, queued_bytes, queue_errors;
uint64_t sent_frames, sent_bytes, send_errors, retired;
web_serial_performance_timing_t queue_wait, send_call;
web_serial_performance_timing_t completion_attempt, completion_nonempty;
web_serial_performance_timing_t completion_first_nonempty;
} web_serial_performance_session_t;
typedef struct {
bool enabled, epoch_exhausted;
uint32_t epoch;
web_serial_performance_session_t sessions[WEB_SERIAL_TRANSPORT_MAX_SESSIONS];
} web_serial_performance_snapshot_t;
/* Binary TX only; no broker/HTTPD queries, heap scans, or sensitive identities.
* queued_* counts transport reservations, including reported queue failures;
* sent_* counts successful send-call returns. send_errors includes owner-context
* rejection; send_call timings count only actual API calls. queue_wait includes
* owned callbacks retired without sending. Pending age is since reservation-path
* entry, including an executing send; unavailable epochs are explicitly marked.
* All timing endpoints are local monotonic estimates, never peer acknowledgments.
* Disable freezes aggregates; enable resumes them. Every toggle/clear fences
* in-flight samples. Clear preserves enabled state. Epoch exhaustion fails closed.
* Nonempty completion intervals include idle; first_nonempty requires the first
* subsequent read to return data (not proof of backlog at send completion). */
esp_err_t web_serial_performance_enable(bool enabled);
esp_err_t web_serial_performance_clear(void);
esp_err_t web_serial_performance_snapshot(web_serial_performance_snapshot_t *out);
/* Clearing counters does not alter tickets, sessions, ownership, or queued data. */
esp_err_t web_serial_transport_clear_counters(void);