Repository navigation
perf(courier): sleep until the next job, and deliver as a bot gets ready - #79
Merged
Merged
Conversation
The courier woke every 500 ms, idle or not, and ran three queries under the store lock each time. A message to a bot that was starting waited for its 5 s check even when the bot was ready after 1.5 s. - Between cycles the courier sleeps until the first delivery of a bot's queue comes due, a lease runs out or an open task passes its deadline; at least 250 ms, at most poll_interval_ms, whose default goes from 500 ms to 10 s since it is now only the ceiling. New messages and finished sends still wake it at once. - It follows bot.state: when a bot can take messages again, its deliveries that never failed come due at once. Those that failed keep their backoff, so a message that makes the bot crash does not come straight back. - Tests that waited for Idle and moved the clock 5 s to release a message no longer need to; a new test checks a message that waited for a paused bot goes on resume without the clock moving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sixth and last slice of the performance round. It is independent of the others. It touches
deliveries.rslike #74, in different spots.What changes
courier_next_at).poll_interval_ms, whose default goes from 500 ms to 10 s: it is now only the ceiling.bot.state. When a bot can take messages again, its deliveries that never failed (attempts = 0) come due at once.Not done here: the reconcile every 5 s.
release_limitsdepends on it, and thesession_idN+1 there is small.Tests
a_message_that_waited_for_the_bot_goes_as_soon_as_it_is_ready: a message sent while the bot is paused goes on resume without moving the manual clock. It fails without the change (I checked).Idleand moved the clock 5 s to release a message. They no longer need to: the bot isBusybefore it can be seenIdle. The backoff test (attempts≥ 1) still waits for the clock, as it should.tests/courier.rsdropped from 8 s to 0.3 s.cargo fmt,clippy -D warnings,cargo test --workspace(three times) pass locally.Manual check (real Claude)
botloftd.exe) CPU in Task Manager stays near zero.