Skip to content

Fix race condition in testHighPriorityTasksGetExecutedBeforeLowPriorityTasks #2012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Feb 26, 2025

The assertion in this test was too strict. Even if the high priority tasks are scheduled first, they might finish after the low priority tasks (both high-priority and low-priority tasks sleep 100ms in these tests). For example the following is a valid recording of executions.

Set([high(0)])
Set([high(1), high(0)])
Set([high(1), high(2), high(0)])
Set([high(2), high(0), high(3), high(1)])
Set([high(2), high(3), high(1)])
Set([high(2), high(1)])
Set([high(2)])
Set([])
Set([high(4)])
Set([high(5), high(4)])
Set([high(6), high(5), high(4)])
Set([high(6), high(5), high(7), high(4)])
Set([high(6), high(5), high(7)])
Set([high(5), high(7)])
Set([high(5)])
Set([])
Set([high(8)])
Set([high(8), high(9)])
Set([high(8), high(9), low(0)])
Set([high(8), high(9), low(0), low(1)])
Set([high(8), high(9), low(0)])
Set([high(8), high(9)])
Set([high(9)])

Change the assertion to check that all high-priority tasks start executing before the first low-priority task starts executing.

rdar://145660858

…ityTasks`

The assertion in this test was too strict. Even if the high priority tasks are scheduled first, they might finish after the low priority tasks (both high-priority and low-priority tasks sleep 100ms in these tests). For example the following is a valid recording of executions.

```
Set([high(0)])
Set([high(1), high(0)])
Set([high(1), high(2), high(0)])
Set([high(2), high(0), high(3), high(1)])
Set([high(2), high(3), high(1)])
Set([high(2), high(1)])
Set([high(2)])
Set([])
Set([high(4)])
Set([high(5), high(4)])
Set([high(6), high(5), high(4)])
Set([high(6), high(5), high(7), high(4)])
Set([high(6), high(5), high(7)])
Set([high(5), high(7)])
Set([high(5)])
Set([])
Set([high(8)])
Set([high(8), high(9)])
Set([high(8), high(9), low(0)])
Set([high(8), high(9), low(0), low(1)])
Set([high(8), high(9), low(0)])
Set([high(8), high(9)])
Set([high(9)])
```

Change the assertion to check that all high-priority tasks start executing before the first low-priority task starts executing.

rdar://145660858
@ahoppen
Copy link
Member Author

ahoppen commented Feb 26, 2025

@swift-ci Please test

@ahoppen ahoppen merged commit fc0db35 into swiftlang:main Feb 27, 2025
3 checks passed
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