Skip to content

Add throttled high-rate MQTT publish warnings in runtime client - #164

Draft
mwfarb with Copilot wants to merge 5 commits into
mainfrom
copilot/high-mqtt-publish-rate-warnings
Draft

Add throttled high-rate MQTT publish warnings in runtime client#164
mwfarb with Copilot wants to merge 5 commits into
mainfrom
copilot/high-mqtt-publish-rate-warnings

Conversation

Copilot AI commented Jul 12, 2026

Copy link
Copy Markdown

High outbound MQTT publish rates could occur silently, making accidental publish loops hard to detect during runtime. This change adds lightweight rate monitoring in the publish path and emits console warnings only when publish throughput is unusually high.

  • Publish-rate detection at MQTT egress

    • Added rate tracking in ArenaMqttClient.Publish(...), where scene/object/camera outbound messages converge.
    • Computes observed throughput over a short rolling window and compares against a warning threshold.
  • Operator-facing warning behavior

    • Emits Debug.LogWarning when publish rate exceeds the threshold.
    • Warning text includes observed rate and threshold, plus the relevant update knobs (globalUpdateMs, objectUpdateMs, cameraUpdateMs).
  • Noise and safety controls

    • Added warning cooldown to prevent log spam under sustained high throughput.
    • Synchronized rate-tracking state to keep counters/timestamps consistent if publish calls arrive concurrently.
float msgsPerSecond = publishedMsgsInWindow / elapsed;
if (msgsPerSecond >= publishRateWarningThresholdMsgsPerSecond &&
    now - lastPublishRateWarningTime >= publishRateWarningCooldownSeconds)
{
    Debug.LogWarning(
        $"High MQTT publish rate detected: {msgsPerSecond:F1} messages/s over {elapsed:F1}s " +
        $"(threshold: {publishRateWarningThresholdMsgsPerSecond:F0} messages/s). " +
        "Consider reducing update frequency (globalUpdateMs, objectUpdateMs, cameraUpdateMs)."
    );
}

Copilot AI changed the title [WIP] Add console warnings for high MQTT publish rates Add throttled high-rate MQTT publish warnings in runtime client Jul 12, 2026
Copilot AI requested a review from mwfarb July 12, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

high mqtt publish rates should log console warnings

2 participants