Start tests in sorted order also with multiple threads#141
Open
giordano wants to merge 3 commits into
Open
Conversation
Since #119, each test is bound to its own task at spawn time, and all tasks race to acquire the semaphore. With a single thread tasks happen to reach the semaphore in spawn order, but with multiple threads the acquisition order is arbitrary, defeating the descending-historical- duration sort (#139). Instead, hand out tests in sorted order at acquisition time, via an atomic fetch-add index claimed only once a task holds a semaphore slot and a worker. Fixes #139. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
giordano
commented
Jul 2, 2026
Collaborator
Author
|
To demonstrate that this PR does solve #139, in this CI run I reverted the fix introduced in this PR, but only kept running the CI jobs with multiple Julia threads: in 11 out of 20 jobs, the tests introduced in #140 failed, as expected. Tests are instead all green when running Julia with multiple threads and applying the proposed fix. |
Contributor
|
This seems to also work for me! |
Collaborator
Author
|
Ok, I verified the new tests would occasionally fail before this PR, when running Julia with multiple threads, so this is ready to go from my side. |
This comment was marked as resolved.
This comment was marked as resolved.
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.
Since #119, each test is bound to its own task at spawn time, and all tasks race to acquire the semaphore. With a single thread tasks happen to reach the semaphore in spawn order, but with multiple threads the acquisition order is arbitrary, defeating the descending-historical- duration sort (#139).
Instead, hand out tests in sorted order at acquisition time, via an atomic fetch-add index claimed only once a task holds a semaphore slot and a worker.
Fixes #139. @christiangnrd can you please test this PR? It does seem to work for me, tests introduced in #140 now pass when using multiple Julia threads, which instead very frequently currently fail, as explained in #140 (comment).