Skip to content

Commit 84d488c

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 c225a1c commit 84d488c

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
@@ -1050,8 +1050,7 @@ static void wakeOverrides(ProcessOverrideJob *nextOverride,
10501050
nextOverride = cur->NextJob.getAsPreprocessedOverride();
10511051

10521052
if (hasAlreadyActivated ||
1053-
!targetPriority ||
1054-
cur->getPriority() != *targetPriority)
1053+
!targetPriority)
10551054
cur->wakeAndAbandon();
10561055
else
10571056
hasAlreadyActivated = cur->wakeAndActivate();
@@ -1214,8 +1213,7 @@ void DefaultActorImpl::giveUpThread(RunningJobInfo runner) {
12141213
}
12151214

12161215
bool hasMoreJobs = (bool) newState.FirstJob;
1217-
bool hasOverrideAtNewPriority =
1218-
(runner.Priority < oldState.Flags.getMaxPriority());
1216+
bool hasOverrideAtNewPriority = false;
12191217
bool hasActiveInlineJob = newState.Flags.hasActiveInlineJob();
12201218
bool needsNewProcessJob = hasMoreJobs && !hasOverrideAtNewPriority;
12211219

@@ -1316,8 +1314,7 @@ Job *DefaultActorImpl::claimNextJobOrGiveUp(bool actorIsOwned,
13161314

13171315
// If the actor is out of work, or its priority doesn't match our
13181316
// priority, don't try to take over the actor.
1319-
if (!oldState.FirstJob ||
1320-
oldState.Flags.getMaxPriority() != runner.Priority) {
1317+
if (!oldState.FirstJob) {
13211318

13221319
// The only change we need here is inline-runner bookkeeping.
13231320
if (!tryUpdateForInlineRunner())
@@ -1399,8 +1396,7 @@ Job *DefaultActorImpl::claimNextJobOrGiveUp(bool actorIsOwned,
13991396
// FIXME: should this be an exact match in priority instead of
14001397
// potentially running jobs with too high a priority?
14011398
Job *jobToRun;
1402-
if (oldState.Flags.getMaxPriority() <= runner.Priority &&
1403-
newFirstJob) {
1399+
if (newFirstJob) {
14041400
jobToRun = newFirstJob;
14051401
newState.FirstJob = getNextJobInQueue(newFirstJob);
14061402
newState.Flags.setStatus(Status::Running);
@@ -1646,7 +1642,7 @@ void DefaultActorImpl::enqueue(Job *job) {
16461642

16471643
// If we need an override job, create it (if necessary) and
16481644
// register it with the queue.
1649-
bool needsOverride = !wasIdle && newPriority != oldPriority;
1645+
bool needsOverride = false;
16501646
if (needsOverride) {
16511647
overrideJob.addToState(this, newState);
16521648
} 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)