Skip to content

Keep FromLastCompletion polling on its grid when the next run is due sooner [patch] - #102

Merged
matt-edmondson merged 3 commits into
mainfrom
fix/101-bounded-polling-extension
Nov 11, 2026
Merged

matt-edmondson merged 3 commits into
mainfrom
fix/101-bounded-polling-extension

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #101

What changed

WaitOutPollingIntervalAsync used to extend the wait to a full PollingInterval past any run that finished during it. When ActionInterval plus the run time fits inside one polling interval, the next run is already due on the next tick, so that extension pushed every cycle back by the run time. At the defaults (1 s polling, ActionInterval 0, FromLastCompletion) a 900 ms action ended up running about every 1.9 s.

The wait is now max(PollingInterval - (now - start), min(ActionInterval, PollingInterval) - (now - completedAt)). With equal intervals that is the same as before, so #93 stays fixed. The <remarks> now describe the bounded extension.

Tests


Generated by Claude Code

…sooner [patch]

The polling wait was extended to a full PollingInterval past a run that
finished during it, so when ActionInterval plus the run time fit inside one
polling interval every cycle slipped by the run time. Extend the wait only
until the run is due: min(ActionInterval, PollingInterval) past completion.

Fixes #101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3tezLDV1yfkEQRQji
…ays under its bound

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3tezLDV1yfkEQRQji

Copy link
Copy Markdown
Contributor Author

ci / .NET / Test on macos-latest failed on 8f3fa6f in 3 tests:

  • ShortActionIntervalKeepsToThePollingGridInFromLastCompletion (the new test). The fixed code ran on its grid (gaps of 500–660 ms at a 500 ms interval). The macOS runner's timer overslept by 100–160 ms, which pushed the longest gap past the 1.25× bound (625 ms). e8ba697 moves the test to a 1 s interval with 600/500 ms of work. That keeps the same 1.25× criterion but leaves room for that oversleep. Locally the fix passes, and without the fix the test fails with gaps of 1.5–1.6 s.
  • EqualPollingAndActionIntervalsSkipNoTicks (FromLastCompletion,20) (the existing With the default FromLastCompletion, equal polling and action intervals still skip ticks: a 5 ms action set to every 1 s runs every 2 s #93 test): 770 ms against a 750 ms bound, at 500 ms polling. The diff doesn't change behaviour for equal intervals: when ActionInterval == PollingInterval, max(PI − since start, min(AI, PI) − since completion) comes out the same as before. The same run had gaps of 570–770 ms throughout, so this looks like the same runner oversleeping, not this change. Main's last macOS test run passed. If it fails again on e8ba697, I'll treat it as real and fix it.

Generated by Claude Code

…p stays under its bound

The test failed twice on macos-latest with gaps of 770 and 809 ms against a
750 ms bound at 500 ms polling, with no tick skipped (that would be ~1000 ms).
At 1 s the 1.5x bound leaves 500 ms for oversleep, and the #93 regression
still fails it with 2 s gaps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3tezLDV1yfkEQRQji

Copy link
Copy Markdown
Contributor Author

On e8ba697, the new test passed on macOS. EqualPollingAndActionIntervalsSkipNoTicks (FromLastCompletion,20) failed again: 809 ms against 750 ms, with steady gaps of about 630 ms. That is the runner adding roughly 130 ms per cycle plus spikes. It isn't a skipped tick, which would be about 1000 ms. Because it failed twice, I treated it as real. 9b1c728 runs that test at a 1 s interval, so the 1.5× bound leaves 500 ms for oversleep.

I checked that it still catches #93: with the completion-based extension disabled locally, the FromLastCompletion rows fail with 2 s gaps.


Generated by Claude Code

@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

2 participants