Skip to content

[Executors] Ensure we treat DA older than 5.9 always as DefaultActor #64800

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

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Mar 31, 2023

This is because cross module references to a RESILIENT actor would have short circuited and returned false for such actor, while an old compiler does not have code to handle the "NON default distributed actor" paths, so it would result in compile issues in HopToActor optimization

@ktoso ktoso requested a review from DougGregor March 31, 2023 02:42
// 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
Contributor Author

Choose a reason for hiding this comment

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

This is the core of the change; we ensure we treat distributed actors which "could not have been non-default" always as default.

tests.test("5.7 actor, 5.9 executor property => no custom executor") {
expectCrashLater(withMessage: "Fatal error: Incorrect actor executor assumption; Expected 'MainActor' executor.")
try! await FiveSevenActor_FiveNineExecutor(actorSystem: system).test(x: 42)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This case I was unsure about, but I think this way to handle it makes sense; the entire actor has to be 5.9 to be treated like being able to have a custom executor, not just the property.

@ktoso ktoso added concurrency Feature: umbrella label for concurrency language features distributed Feature → concurrency: distributed actor labels Mar 31, 2023
@ktoso
Copy link
Contributor Author

ktoso commented Mar 31, 2023

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Mar 31, 2023

Going to debug the linux issue 👀

@ktoso ktoso force-pushed the wip-da-olderthan-59-always-default-actor branch from 1187023 to 931be88 Compare April 3, 2023 11:19
@ktoso ktoso requested a review from tshortli as a code owner April 3, 2023 11:19
@ktoso ktoso force-pushed the wip-da-olderthan-59-always-default-actor branch from 931be88 to 3b4ac6c Compare April 3, 2023 11:20
@ktoso
Copy link
Contributor Author

ktoso commented Apr 3, 2023

Fixed non apple platform issues:

  • silly extra space issue in test: a6ddf44 (#64800)
  • looking for macos availability should have no impact on linux, so adjusted the test for this: 3b4ac6c (#64800)

@ktoso
Copy link
Contributor Author

ktoso commented Apr 3, 2023

@swift-ci please smoke test


/// Returns a representation of this range as a string for debugging purposes.
std::string getAsString() const {
return "AvailabilityContext(" + OSVersion.getAsString() + (isAvailableAsSPI() ? ", spi" : "") + ")";
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: run git-clang-format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll follow up separately if that's fine? That'd just be a linebreak here AFAICS.

-    return "AvailabilityContext(" + OSVersion.getAsString() + (isAvailableAsSPI() ? ", spi" : "") + ")";
+    return "AvailabilityContext(" + OSVersion.getAsString() +
+           (isAvailableAsSPI() ? ", spi" : "") + ")";

// The problem with clang-format is that it is not being applied consistently in this project, so applying it adds all kinds of noise and "this commit does not look like the rest of the file or method at all now..."

Copy link
Contributor

Choose a reason for hiding this comment

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

Follow up is fine with me! I find the clang-format output is pretty consistent with the style of most of the files I have worked in in the project and it is documented in https://github.com/apple/swift/blob/main/docs/HowToGuides/FirstPullRequest.md as the primary way of enforcing the project code style. In particular, long lines stick out a lot - I think the majority of the codebase adheres to the 80 char limit

Copy link
Contributor Author

@ktoso ktoso Apr 4, 2023

Choose a reason for hiding this comment

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

I'll follow up about my specific changes, but the reality is that files are not well formatted:

 22 files changed, 65 insertions(+), 65 deletions(-)

if running clang-format on files this PR touched, out of that my changes would be...

 5 files changed, 22 insertions(+), 15 deletions(-)

but yeah, I'll add a git hook to git-clang-format my commits and I'll do the promised follow up now as well: #64886

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants