Repository navigation
Conversation
Areson
added this pull request to stack #192
October 21, 2026 21:52
Areson
force-pushed
the
Areson/level-collector-stop
branch
2 times, most recently
from
October 22, 2026 14:54
6f91e04 to
b6e3bc9
Compare
Areson
force-pushed
the
Areson/level-collector-stop
branch
from
October 22, 2026 15:51
b6e3bc9 to
5a1b113
Compare
Areson
force-pushed
the
Areson/level-collector-stop
branch
from
October 22, 2026 16:01
5a1b113 to
ac29448
Compare
Areson
force-pushed
the
Areson/level-collector-stop
branch
from
October 22, 2026 17:28
ac29448 to
ebf6b26
Compare
The level collector checked for stop only after each ticker tick, so stopping a monitor waited up to one tick (1s), 0.5s on average. With removals processed one reload at a time, that wait added up to about 0.5s per removed monitor. Run now waits for either the next tick or stop. It still checks for stop after a tick, because select picks randomly when both are ready. Dropped tick counting is unchanged. A collection in progress still finishes before the collector stops; it's bounded by the engine max runtime. Tests drive Run by sending values on a buffered stopChan, one per tick, then closing it. Once Run receives a value, it keeps that one-per-tick behavior, so those tests see the close on the next tick as before. With the 1s tick, a stop that took 0.3s to 0.9s depending on when in the tick it arrived now takes well under a millisecond in the new test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Areson
force-pushed
the
Areson/level-collector-stop
branch
from
October 22, 2026 19:32
ebf6b26 to
66c753e
Compare
This branch has not been deployed
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.
Why
The level collector checks for stop only after each 1 s ticker tick. So a monitor stop waits up to 1 s, 0.5 s on average. When monitors are removed one reload at a time, that adds about 0.5 s per removed monitor.
What
The level collector's
Runloop waits for either the next tick or stop, not just the tick.How
Runstill checks for stop after a tick, becauseselectpicks at random when both are ready.Runby sending one value per tick on a bufferedstopChan, then closing it. OnceRungets a value, it keeps that one-per-tick behavior, so those tests see the close on the next tick as before.Risk
Medium. Behavior change: a stop can now drop a batch that was collected but not yet sent to the sinks. The old code had the same race, but the wait for the next tick usually hid it. That's fine when a monitor stops because it lost its source. It can lose the last interval of metrics on a planned restart.
Testing
A local benchmark ran 400 monitors in one process against 4 MySQL 8.0 servers, with the whole stack applied. In a lock-loss storm, 200 of the 400 monitors lost their source at once, then got it back.
Bigger picture
Top of a stack of 5 fixes found by the same benchmark. Merge the stack bottom-up, starting with #187.
🤖 Generated with Claude Code