Skip to content

refactor(mqtt): drop the redundant sleep between OBSERVE registrations - #59

Merged
QuiteYellow merged 1 commit into
mainfrom
chore/drop-redundant-subscribe-sleep
Aug 22, 2026
Merged

refactor(mqtt): drop the redundant sleep between OBSERVE registrations#59
QuiteYellow merged 1 commit into
mainfrom
chore/drop-redundant-subscribe-sleep

Conversation

@QuiteYellow

Copy link
Copy Markdown
Owner

_run_session_inner slept 50ms after every subscribe() call. subscribe() opens with self.pace(), which withholds the send until _min_req_interval has passed since the last datagram, and the default rate limit is 5 req/s. The sleep was always shorter than the wait that followed it, so no registration ever left the host at a different time because of it.

Noted on #51 and #53.

Deployed to the reference bridge (one dryer, one oven) and soaked. Discarding the window that contains the connect, five 60-second windows on each: dryer 95-96 ok, oven 220-229 ok, no errors, no ping failures and no timeouts on either. Those counts sit inside the pre-change baseline of 94-96 and 222-229. The dryer seeded without the DTLS listener stall a container recreate sometimes causes.

Latency in the steady-state windows also matches baseline (dryer p_max 256-272ms against 221-283ms, oven 2011-2346ms against 1838-1980ms). The two windows containing a link sweep ran above their baseline counterparts, dryer 1151ms against 913ms and oven 3447ms against 2635ms, with slow counts unchanged. Removing a delay cannot add latency, so I read those two as device-side sweep variance. The numbers are here either way.

mqtt_demo/ is outside the distributed package, so this does not reach the wheel.

_run_session_inner slept 50ms after every subscribe() call. subscribe()
opens with self.pace(), which withholds the send until _min_req_interval
has passed since the last datagram, and the default rate limit is 5
req/s. The sleep was always shorter than the wait that followed it, so
no registration ever left the host at a different time because of it.

Noted on #51 and #53.
@QuiteYellow
QuiteYellow merged commit 6d9cf40 into main Aug 22, 2026
8 checks passed
mbillow added a commit to mbillow/SmartThings-Local that referenced this pull request Aug 23, 2026
refresh_observes() dropped every OBSERVE registration in a tight loop.
Unlike the teardown dereg in close(), which wants out quickly and leaves
a session nobody will use again, this one runs against a session that has
to keep working afterwards — and an unpaced OBSERVE burst is what wedges
an appliance until something forces a new session (LocalThings#396).

The two sleeps that stood in for pacing are gone with it. subscribe()
paces its own send since QuiteYellow#51, so the 50ms between registrations was
always shorter than the wait that followed it — the same redundancy QuiteYellow#59
removed from the bridge's registration loop, at the sibling call site.
The 100ms between the two sweeps is subsumed the same way, by the pace
inside the first subscribe().

Note this does not fix the connect-time OBSERVE burst in #396 on its own:
that path is the bridge's registration loop, which QuiteYellow#51 already paces.
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.

1 participant