Repository navigation
fix(watch): one change makes one deadline for every service it concerns (#233) - #239
Merged
Merged
Conversation
…ns (#233) A candidate's pipeline and a debounce looked for the end of their quiet period every 200 ms, counted from when their thread began. The OS reports one change more than once (notify makes an event per FSEvents flag; FSEvents may send a second record; inotify reports a save's truncation and write apart). Each report re-arms every service it concerns at about the same moment, but a thread that began just before the repeat missed its deadline at one look and fired at the next, 200 ms later than another service's. Two services after the same job then built for one edit 240 ms apart, and the job ran again for the second (macOS CI). The waiters now sleep until the deadline itself, wherever a later report moved it: a repeat moves it by the time between the reports, the same for every service. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…233) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…233) `devstack restart` right after an edit builds the tree with the edit, but FSEvents reported it a few milliseconds after the restart had taken in the changes so far. Its candidate came out of the quiet period while the restart was still switching, was no build of main yet, and took over again, running the jobs the service comes after once more (macOS CI, `lifecycle_services_only`). Once the quiet period is over, a candidate now waits for a restart of its service under way; built after it, it is the build main has and is dropped as unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
On macOS,
a_job_runs_once_for_two_candidatesfailed now and then (seedran 3 times, expected 2), and once in this PR's CIlifecycle_services_onlydid too (prep3 times). Both come from how the watcher's reports of one edit meet the waiting in the daemon. Neither was really FSEvents reporting the same change twice, 200 ms apart.Cause
1. One change, two deadlines. A candidate's pipeline (and
Supervisor::debounce) checked every 200 ms whether its quiet period was over, counting from when its thread started. The OS reports one edit several times within milliseconds: notify sends one event per FSEvents flag (created, modified, metadata), and inotify reports a save's truncate and its write separately. Each report re-arms every service it concerns, at about the same moment. In the failing run,bfired exactly 2.010 s after its first report, sob's wait was effectively not moved.a's thread had started about 1 ms before the repeat report, so it missed its deadline at the tenth check and fired at the eleventh, 240 ms later. By then theseedrun forbhad already started, soacounted it as older than its own build and ranseedagain.2. A report that arrives after a restart has begun.
lifecycle_services_onlyeditsProgram.csand runsdevstack restart apistraight away. The restart takes in the changes reported so far, then builds the tree including the edit. FSEvents reported the edit 6 ms after that, so the change looked new. Its candidate's 2 s wait ended while the restart was still switching over. Because the restart's build was not main yet, the candidate was not dropped as unchanged: it took over again and ranprepa third time. Polling every 200 ms would have fired at the same moment, so this race was already there. It only bites when the restart takes longer than the 2 s wait.Fix
quiet_left), wherever a later report moved it. A repeated report moves the deadline by the gap between the reports, and by the same amount for every service, so services that see the same edit still fire together. This holds on every OS, andrestart_onrestarts, the lane copy and the.gitignorereload use the same debounce.lifecycle_services_onlyhas expected since feat: macOS as a developer platform in preview, Homebrew, arm64 Linux (ADR-0054) #225. If the restart fails, the candidate proceeds as before.Options I did not take (the reasoning is in the comment on
quiet_left):watch.rsavoids (LIST_NEW_DIRS). FAT/exFAT store mtime only to 2 s, and a lane's copy, which waits only 150 ms, would miss a second save of the same length. It would also not have prevented either failure.Tests
a_change_reported_twice_makes_one_deadline_for_every_service: one path reported foraandb, and again ~200 ms later. Both services must take their change at the second report's time plus the quiet period, less than 100 ms late and less than 100 ms apart. With the old 200 ms polling, it fails deterministically:a fired 183ms after its deadline, 3 of 3 runs.a_candidate_waits_for_a_restart_under_way: a candidate waits past its quiet period while a restart is under way, and fires within a second after the restart ends.macOS
A temporary job on
macos-14(removed again in this branch) rana_job_runs_once_for_two_candidates10 times in a row withDEVSTACK_INTEGRATION=1, andlifecycle_services_only5 times: 10/10 and 5/5 passed. A first round with only fix 1 was also 10/10. In that runintegration (macos-14)showed the restart race (fix 2).One run of
check (macos-14)failed indevstack-proc'sthe_machine_reports_memory_and_cpu_time(the host's CPU ticks did not advance in 300 ms). That test is unrelated to this change.Closes #233
🤖 Generated with Claude Code