Skip to content

exploreRacesOfThreadsLabelled - #273

Open
jasagredo wants to merge 4 commits into
IntersectMBO:mainfrom
jasagredo:playground-racy-labels
Open

jasagredo wants to merge 4 commits into
IntersectMBO:mainfrom
jasagredo:playground-racy-labels

Conversation

@jasagredo

Copy link
Copy Markdown
Contributor

Used to be able to select which threads should race from outside the production code.

…osen labels

exploreRaces makes the calling thread's future children racy, by their
thread ids. A test of a large system, which forks many threads before it
gets to what it wants to explore, can either make all of them racy, and
spend most of each schedule's race analysis on threads it does not care
about, or none.

exploreRacesOfThreadsLabelled p takes into account, when discovering
races, each thread once it is given a label that satisfies p, until it
is given one that does not. Such a thread's children do not inherit it.
Thread ids do not change, so ScheduleControl replay is unaffected.
runSimTrace ignores it.
So a test can call it once it has set up what it wants to explore: the
threads it started during the set-up race from then on, and the set-up's
own races, which IOSimPOR would otherwise reverse first and spend its
bounds on, are left out. A later call recomputes the set from the new
predicate; calling it with const False stops all racing by label.
…rent

A thread racing by its label now lends that to the threads it forks,
until they are labelled themselves; then their own label decides. A
helper the code forks without a label, such as an async worker, races
with the thread that started it, while a labelled child, such as a
driver's sender, is still left out unless the predicate names it.
@jasagredo
jasagredo requested a review from a team as a code owner November 13, 2026 13:14

@coot coot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution will only make racing threads the threads that were started by one of the thread that were racy by label. The other limitation is that it only applies to threads that exist when one runs the exploreRacesOfThreadsLabelled primitive operation.

I have another solution which doesn't share the latter limitation and it will also allow to make the main thread racy (which is also limitation of the current approach). I'll submit a PR soon, since it's quite simple and it doesn't require any changes to IOSim primitive operations.

labelled = Set.fromList
[ threadId t
| t <- thread : Map.elems threads
, Just l <- [threadLabel t]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, Just l <- [threadLabel t]
, l <- maybeToList (threadLabel t)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants