Skip to content

🍒[5.9][Executors] Clean up how we unwrap the local executor of distributed custom actor #64740

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

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Mar 29, 2023

Description: This removes a hacky workaround in how a "hop to" distributed actor is implemented.
Risk: Low, removes an internal underscored hack; The _ method could not have been used by any adopters yet.
Review by: @DougGregor @slavapestov
Testing: CI testing
Original PR: #64719 #64800

This now includes fixes from (#64800) to how we deal with resilient cross module distributed actors; and treat pre 5.9 distributed actors as ALWAYS default, which we must do in order to properly backwards compatible handle such actors. Thank you @DougGregor for the review and catch.

@ktoso ktoso requested a review from a team as a code owner March 29, 2023 21:29
@ktoso ktoso requested review from slavapestov and DougGregor March 29, 2023 21:29
@ktoso
Copy link
Contributor Author

ktoso commented Mar 29, 2023

@swift-ci please test

auto witnessCall = B.createApply(loc, witness, subs, {actor});
// Find the unwrap function
FuncDecl *funcDecl = ctx.getGetUnwrapLocalDistributedActorUnownedExecutor();
assert(funcDecl);
Copy link
Member

Choose a reason for hiding this comment

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

You are likely to end up having this code run against a standard library that doesn't have this function declaration, because it's older. Can we fail gracefully in such cases?

More urgently, doesn't the use of this new function break back-deployment for distributed actors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed this and I believe we should address this a little bit, the proposed solution is here: #64800

It specifically is about resilient "old" distributed actors being potentially marked as non default while they should still be default

Copy link
Contributor Author

@ktoso ktoso Apr 3, 2023

Choose a reason for hiding this comment

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

Done in #64800 and cherry picked into this PR as well @DougGregor

@ktoso ktoso added concurrency Feature: umbrella label for concurrency language features distributed Feature → concurrency: distributed actor 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 labels Mar 31, 2023
@ktoso ktoso requested a review from DougGregor April 3, 2023 11:24
@ktoso
Copy link
Contributor Author

ktoso commented Apr 3, 2023

@swift-ci please test

Comment on lines +188 to +202
if (classDecl->isDistributedActor()) {
ASTContext &ctx = classDecl->getASTContext();
auto customExecutorAvailability =
ctx.getConcurrencyDistributedActorWithCustomExecutorAvailability();

auto actorAvailability = TypeChecker::overApproximateAvailabilityAtLocation(
classDecl->getStartLoc(),
classDecl);

if (!actorAvailability.isContainedIn(customExecutorAvailability)) {
// Any 'distributed actor' declared with availability lower than the
// introduction of custom executors for distributed actors, must be treated as default actor,
// even if it were to declared the unowned executor property, as older compilers
// do not have the the logic to handle that case.
return true;
Copy link
Member

Choose a reason for hiding this comment

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

This looks great, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! And thank you for noticing the issue to begin with!

@ktoso ktoso merged commit 954cb6f into swiftlang:release/5.9 Apr 4, 2023
@ktoso ktoso deleted the pick-cleanup-hop-to-distributed-custom-executor branch April 4, 2023 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency Feature: umbrella label for concurrency language features distributed Feature → concurrency: distributed actor 🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants