Skip to content

Commit 2168f6c

Browse files
committed
Ignore task priorities in the actor runtime.
The actor runtime has some known issues with deadlock when an actor has to give up its thread because it's running lower-priority work. To avoid deadlocks here, disable all of the logic that tries to give up higher-priority threads when only lower-priority work is available, or to escalate work, effectively making the actor runtime ignore priorities internally. Fixes rdar://79378762.
1 parent 1cac3ee commit 2168f6c

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,7 @@ static void wakeOverrides(ProcessOverrideJob *nextOverride,
10241024
nextOverride = cur->NextJob.getAsPreprocessedOverride();
10251025

10261026
if (hasAlreadyActivated ||
1027-
!targetPriority ||
1028-
cur->getPriority() != *targetPriority)
1027+
!targetPriority)
10291028
cur->wakeAndAbandon();
10301029
else
10311030
hasAlreadyActivated = cur->wakeAndActivate();
@@ -1187,8 +1186,7 @@ void DefaultActorImpl::giveUpThread(RunningJobInfo runner) {
11871186
}
11881187

11891188
bool hasMoreJobs = (bool) newState.FirstJob;
1190-
bool hasOverrideAtNewPriority =
1191-
(runner.Priority < oldState.Flags.getMaxPriority());
1189+
bool hasOverrideAtNewPriority = false;
11921190
bool hasActiveInlineJob = newState.Flags.hasActiveInlineJob();
11931191
bool needsNewProcessJob = hasMoreJobs && !hasOverrideAtNewPriority;
11941192

@@ -1287,8 +1285,7 @@ Job *DefaultActorImpl::claimNextJobOrGiveUp(bool actorIsOwned,
12871285

12881286
// If the actor is out of work, or its priority doesn't match our
12891287
// priority, don't try to take over the actor.
1290-
if (!oldState.FirstJob ||
1291-
oldState.Flags.getMaxPriority() != runner.Priority) {
1288+
if (!oldState.FirstJob) {
12921289

12931290
// The only change we need here is inline-runner bookkeeping.
12941291
if (!tryUpdateForInlineRunner())
@@ -1370,8 +1367,7 @@ Job *DefaultActorImpl::claimNextJobOrGiveUp(bool actorIsOwned,
13701367
// FIXME: should this be an exact match in priority instead of
13711368
// potentially running jobs with too high a priority?
13721369
Job *jobToRun;
1373-
if (oldState.Flags.getMaxPriority() <= runner.Priority &&
1374-
newFirstJob) {
1370+
if (newFirstJob) {
13751371
jobToRun = newFirstJob;
13761372
newState.FirstJob = getNextJobInQueue(newFirstJob);
13771373
newState.Flags.setStatus(Status::Running);
@@ -1614,7 +1610,7 @@ void DefaultActorImpl::enqueue(Job *job) {
16141610

16151611
// If we need an override job, create it (if necessary) and
16161612
// register it with the queue.
1617-
bool needsOverride = !wasIdle && newPriority != oldPriority;
1613+
bool needsOverride = false;
16181614
if (needsOverride) {
16191615
overrideJob.addToState(this, newState);
16201616
} else {

test/Concurrency/Runtime/async.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// REQUIRES: concurrency
66
// REQUIRES: libdispatch
77

8-
// rdar://76038845
98
// UNSUPPORTED: use_os_stdlib
109

1110
import Dispatch

0 commit comments

Comments
 (0)