Skip to content

[Distributed] prevent remote distributed actor's from running deinit bodies #60050

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 2 commits into from
Jul 15, 2022

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Jul 14, 2022

Deinit bodies should not run for remote distributed actors since they have no state at all, and any such user defined deinit will be wrong.

Resolves: rdar://96980182
Reported in https://forums.swift.org/t/pitch-distributed-actor-runtime/54045/15

@ktoso ktoso force-pushed the wip-deinit-test-da branch from 4182dd9 to fbfe72f Compare July 14, 2022 08:36
auto managedSelf = ManagedValue::forBorrowedRValue(selfValue);

auto selfTy = F.mapTypeIntoContext(cd->getDeclaredInterfaceType());
emitDistributedIfRemoteBranch(
Copy link
Contributor

@nickolas-pohilets nickolas-pohilets Jul 14, 2022

Choose a reason for hiding this comment

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

For isolated deinit I need this check to live inside deallocating deinit. Because isolation happens in deallocating deinit, and remote proxies don't need isolation. I would really appreciate if you could place the check already in the deallocating deinit, so that I don't need to move it later.

See isolated deinit proposal

Copy link
Contributor Author

@ktoso ktoso Jul 14, 2022

Choose a reason for hiding this comment

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

As I'd like to cherry-pick this over to 5.7 so it gets has a chance to get into the release still, and we're a bit limited in how big "risk" changes we can take there, I'd I'd like to keep this PR as minimal as possible and only focused on fixing the bug. We can refactor and change things around later though.

I'm happy to do that in a follow up PR later on 👍

@ktoso ktoso force-pushed the wip-deinit-test-da branch from fbfe72f to 60c015d Compare July 14, 2022 08:50
@ktoso ktoso force-pushed the wip-deinit-test-da branch from 60c015d to 027c4a6 Compare July 14, 2022 08:56
@ktoso
Copy link
Contributor Author

ktoso commented Jul 14, 2022

@swift-ci please smoke test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

LGTM!

@ktoso
Copy link
Contributor Author

ktoso commented Jul 15, 2022

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 7349383 into swiftlang:main Jul 15, 2022
@@ -554,20 +557,21 @@ SILGenFunction::emitConditionalResignIdentityCall(SILLocation loc,

void SILGenFunction::emitDistributedActorClassMemberDestruction(
Copy link
Contributor

Choose a reason for hiding this comment

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

emitDistributedActorClassMemberDestruction() and emitConditionalResignIdentityCall() seem to be dead

B.createBranch(SILLocation(Loc), finishBB);
}
}

emitProfilerIncrement(dd->getTypecheckedBody());
Copy link
Contributor

@nickolas-pohilets nickolas-pohilets Jul 16, 2022

Choose a reason for hiding this comment

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

IIUC, this can be emitted into remoteBB after branch instruction, creating incorrect SIL. Should it be after B.emitBlock(deinitBodyBB)?

Would be nice to have a unit test for deinit and profiling.

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.

5 participants