Skip to content

Dispatcher: carry the TX budget's fractional refill over - #3990

Open
h0lad wants to merge 1 commit into
meshcore-dev:devfrom
h0lad:h0lad_airtime_bucket_fix
Open

h0lad wants to merge 1 commit into
meshcore-dev:devfrom
h0lad:h0lad_airtime_bucket_fix

Conversation

@h0lad

@h0lad h0lad commented Nov 28, 2026

Copy link
Copy Markdown

Truncating the refill on every update lost up to 1 ms per call, so the budget refilled up to ~40% slower than the configured duty cycle.

Fixes #3988

Truncating the refill on every update lost up to 1 ms per call, so the
budget refilled up to ~40% slower than the configured duty cycle.

Fixes meshcore-dev#3988
@h0lad
h0lad marked this pull request as ready for review November 29, 2026 10:29
@MarkRose

Copy link
Copy Markdown

I checked this on a host harness that compiles the real Dispatcher.cpp and calls updateTxBudget() every P ms for 10 s, starting from an empty budget. On current dev the refill comes up short whenever elapsed * duty isn't a whole number. Examples: af=1 with a 3 ms loop is -33%, af=1.5 with a 7 ms loop is -29%, and af=3 with a 7 ms loop is -43%. With this PR every case I tried (af 0/0.5/1/1.5/2/3/9, loop 1/3/7/50 ms) ends within 1 ms of elapsed/(1+af).

I also checked a millis() rollover, a 6 h idle (still clamps to max_budget), and that the carry stays in [0, 1) over 200k calls with varying intervals. I ran it under ASan/UBSan with nothing reported. Heltec_v3_repeater and RAK_4631_repeater both build.

One small difference from the issue's suggestion: the carry isn't zeroed when the budget clamps at max. It's always under 1 ms, so I don't think it matters.

Reviewed with Claude (AI); I checked the findings before posting.

This branch has not been deployed

No deployments
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.

2 participants