Repository navigation
fix(exec): skip the 50 ms sweep retry when every new process was readable - #539
Open
cristianob wants to merge 1 commit into
Open
cristianob wants to merge 1 commit into
cristianob wants to merge 1 commit into
Conversation
…able sweep() slept 50 ms and scanned again whenever the first SIGHUP scan found no scope members, which put a floor under every exec. Retry only when that scan met a process newer than the token whose environment it could not read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What happened
Even a command that exits immediately, such as
hc exec /usr/bin/printf ready, takes longer than it needs to. The caller waits for cleanup before it gets the result.Cause
When the first SIGHUP scan finds no scope members,
sweep()always sleeps for 50 ms and scans again. A retry can catch a process whose environment was briefly unreadable duringexec.Fix
Keep the 50 ms retry when the first scan finds no scope members and encounters a process that started at or after the oldest token timestamp whose environment it cannot read. If that scan has no members and no unreadable candidates, return immediately.
A process of another user that started during the exec also counts as unreadable, so on a busy host some calls still take the retry. That is the previous behaviour, never less safe.
Test
sweep_waits_if_a_new_process_has_no_readable_environmentstarts a Linux process with an empty environment and checks thatsweep()still waits at least 50 ms and leaves the process running.hc exec /usr/bin/printf readyreturned the expected output on every run. Across 30 calls per build after warm-up, the median went from 90.73 ms onmasterto 16.35 ms with the fix. The same check failed before the fix and passed after it with a 60 ms median threshold.just checkpassed with the CI toolchain and test debug settings, using two test threads.🤖 Generated with Claude Code