Skip to content

[Distributed] Fix when we invoke thunk, base it on typesystem implicit effects #39542

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
Oct 2, 2021

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Oct 1, 2021

This solves: https://github.com/apple/swift/pull/39523/files#r719927958 which actually was not only meh style but actually wrong! It caused us to never call the distributed thunk ⚠️

I also unlocked the https://github.com/apple/swift/compare/main...ktoso:remote-calls-bad?expand=1#diff-72a02f8df5425bc51b955369eac5037b49dc42971a6788d8de9dbc79e296d1f7 which shows the issue... (Long story why it was disabled... there's a PR reviving all those tests)

@ktoso ktoso requested review from DougGregor and kavon October 1, 2021 12:27
@ktoso ktoso removed request for kavon and DougGregor October 1, 2021 12:38
@ktoso ktoso self-assigned this Oct 1, 2021
@ktoso ktoso marked this pull request as draft October 1, 2021 12:38
@ktoso ktoso removed their assignment Oct 1, 2021
@ktoso ktoso added the distributed Feature → concurrency: distributed actor label Oct 1, 2021
@ktoso ktoso self-assigned this Oct 1, 2021
@ktoso ktoso force-pushed the remote-calls-bad branch from 6695616 to 4416b13 Compare October 1, 2021 15:31
@ktoso ktoso removed their assignment Oct 1, 2021
@ktoso ktoso requested a review from DougGregor October 1, 2021 15:31
@ktoso
Copy link
Contributor Author

ktoso commented Oct 1, 2021

Solved! We now have a shouldApplyDistributedThunk that captures the logic.

@ktoso ktoso marked this pull request as ready for review October 1, 2021 15:31
@ktoso ktoso force-pushed the remote-calls-bad branch from 4416b13 to ebdb061 Compare October 1, 2021 15:47
@@ -11,8 +11,6 @@
// rdar://77798215
// UNSUPPORTED: OS=windows-msvc

// REQUIRES: rdar78290608
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we enable all of them in #38914

@ktoso
Copy link
Contributor Author

ktoso commented Oct 1, 2021

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Oct 1, 2021

@swift-ci please build toolchain

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Getting closer!

@ktoso ktoso force-pushed the remote-calls-bad branch 2 times, most recently from 6fa8a24 to 85ba3fc Compare October 2, 2021 01:16
@ktoso ktoso force-pushed the remote-calls-bad branch from 85ba3fc to bf0681d Compare October 2, 2021 01:28
@ktoso
Copy link
Contributor Author

ktoso commented Oct 2, 2021

@swift-ci please build toolchain

@ktoso
Copy link
Contributor Author

ktoso commented Oct 2, 2021

@swift-ci please smoke test

@swift-ci
Copy link
Contributor

swift-ci commented Oct 2, 2021

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - bf0681d

Install command
tar zxf swift-PR-39542-688-ubuntu16.04.tar.gz
More info

case ActorIsolation::DistributedActorInstance: {
case ActorIsolation::DistributedActorInstance:
markNearestCallAsImplicitly(/*setAsync*/None, /*setThrows*/false,
/*setDistributedThunk*/true);
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this. It doesn't seem like setThrows can ever be false while setDistributedThunk is true, because you can't do a distributed call without the potential for an error to be thrown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think we can collapse the two - an implicit throws (currently) always implies that it's a distributed call. I wasn't sure if we want to keep it separate, technically there could be other reasons for an implicit throw in the future I guess...?

We also need to cause the think even if the implicit throws is not in effect because the func is throwing anyway

@@ -2277,7 +2281,10 @@ namespace {
} else if (func->isDistributed()) {
tryMarkImplicitlyAsync(memberLoc, memberRef, context,
ImplicitActorHopTarget::forInstanceSelf());
tryMarkImplicitlyThrows(memberLoc, memberRef, context);
tryMarkImplicitlyThrows(memberLoc, memberRef, context);
markNearestCallAsImplicitly(/*setAsync*/None, /*setThrows*/false,
Copy link
Member

Choose a reason for hiding this comment

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

Oh, this is because the tryMarkImplicitThrows is separate. Huh.

ThrowsIsSet : 1,
Throws : 1,
ImplicitlyAsync : 1,
ImplicitlyThrows : 1,
NoAsync : 1
NoAsync : 1,
ShouldApplyDistributedThunk : 1
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be set to false in the ApplyExpr constructor, or you'll end up with spuriously-distributed calls due to uninitialized memory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh man, thanks I totally forgot about that 😱

@DougGregor
Copy link
Member

Merging, and will do a little more cleanup as follow-up

@DougGregor DougGregor merged commit 08eb6ec into swiftlang:main Oct 2, 2021
@ktoso
Copy link
Contributor Author

ktoso commented Oct 2, 2021

Thank you 😊

@swift-ci
Copy link
Contributor

swift-ci commented Oct 2, 2021

macOS Toolchain
Download Toolchain
Git Sha - bf0681d

Install command
tar -zxf swift-PR-39542-1148-osx.tar.gz --directory ~/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed Feature → concurrency: distributed actor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants