Skip to content

Use exponential backoff for USB report retry throttle#1559

Open
kareltucek wants to merge 1 commit into
masterfrom
fix/usb-retry-exponential-backoff
Open

Use exponential backoff for USB report retry throttle#1559
kareltucek wants to merge 1 commit into
masterfrom
fix/usb-retry-exponential-backoff

Conversation

@kareltucek
Copy link
Copy Markdown
Collaborator

The previous fixed 10 ms minimum retry delay caused mouse-key stutter when USB reported "busy" rather than a hard error: every busy reply pushed the next attempt out by a full 10 ms.

Refactor ShouldResendReport into a simple retry counter plus a new GetResendThrottleDelay() that returns the per-attempt delay. The schedule is 1, 2, 4, 8, 16, 32 ms and then capped at 32 ms; MAX_RETRIES is sized so the cumulative wait stays at the original ~1024 ms budget.

Also switches the synchronous dongle resend loop in messenger.c (which already called ShouldResendReport) to the new counter semantics implicitly.

Changelog:

  • make usb retries back off exponentially.

The previous fixed 10 ms minimum retry delay caused mouse-key stutter when
USB reported "busy" rather than a hard error: every busy reply pushed the
next attempt out by a full 10 ms.

Refactor ShouldResendReport into a simple retry counter plus a new
GetResendThrottleDelay() that returns the per-attempt delay. The schedule
is 1, 2, 4, 8, 16, 32 ms and then capped at 32 ms; MAX_RETRIES is sized so
the cumulative wait stays at the original ~1024 ms budget.

Also switches the synchronous dongle resend loop in messenger.c (which
already called ShouldResendReport) to the new counter semantics implicitly.
@pcooke9
Copy link
Copy Markdown

pcooke9 commented May 22, 2026

Thanks, I can confirm this fixes the mouse keys jitter via USB. I'm not sure if improved movement via dongle is also expected or not, but it's still pretty jittery for me.

@kareltucek
Copy link
Copy Markdown
Collaborator Author

When did the dongle jitter start? Was it present in 17.0.0.?

@pcooke9
Copy link
Copy Markdown

pcooke9 commented May 22, 2026

Well, a really long time ago 😅. It started way back in #1114

Sorry, I don't think it's worse recently or anything though. I just don't understand the "dev speak" for whatever you said here 😅:

Also switches the synchronous dongle resend loop in messenger.c (which already called ShouldResendReport) to the new counter semantics implicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants