Skip to content

[region-isolation] Fix join to be a true union operation including the symmetric difference. #69423

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

gottesmm
Copy link
Contributor

We were performing a union on the intersection of the lhs/rhs but were dropping
the parts of lhs/rhs that were in the symmetric difference of the two sets.

Without this, we would not diagnose cases like this where we had elements on the
lhs/rhs that were not in the intersection.

var closure: () -> () = {}

await transferToMain(closure)

if await booleanFlag {
   closure = {
     print(self.klass)
   }
} else {
   closure = {}
}
// At this point we would lose closure since they were different elements

await transferToMain(closure) // We wouldn't error on this!

rdar://117437059

…st CMakeLists.txt

I forgot to do this when moving the unittests so we were not building/running them.
…e symmetric difference.

We were performing a union on the intersection of the lhs/rhs but were dropping
the parts of lhs/rhs that were in the symmetric difference of the two sets.

Without this, we would not diagnose cases like this where we had elements on the
lhs/rhs that were not in the intersection.

```
var closure: () -> () = {}

await transferToMain(closure)

if await booleanFlag {
   closure = {
     print(self.klass)
   }
} else {
   closure = {}
}
// At this point we would lose closure since they were different elements

await transferToMain(closure) // We wouldn't error on this!
```

rdar://117437059
@gottesmm gottesmm requested a review from xedin October 26, 2023 00:05
@gottesmm gottesmm requested review from ktoso and kavon as code owners October 26, 2023 00:06
@gottesmm gottesmm requested a review from slavapestov October 26, 2023 00:09
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

I messed up a little bit of the output from one test for without region isolation when I updated it for region isolation... oops. Posting a commit.

@gottesmm gottesmm force-pushed the pr-4c7e13d3cbc1677f17c72b86d9a02042e97eded1 branch from 96ec732 to 93e98aa Compare October 26, 2023 01:01
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

1 similar comment
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

public:
/// A class defined in PartitionUtils unittest used to grab state from
/// Partition without exposing it to other users.
struct PartitionTester;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be declared in the test fixture and become a friend struct here instead that way getRegion could also be declared in the tester struct itself?

return p;

Region max_index =
Region(*std::max_element(indices.begin(), indices.end()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe fresh_label could be assigned after we went over indices, seems like max_index could be computed by that loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

ASSERT_EQ(tester.getRegion(41), 13);
ASSERT_EQ(tester.getRegion(42), 33);
ASSERT_EQ(tester.getRegion(43), 13);
ASSERT_EQ(tester.getRegion(44), 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

A suggestion for future testing - random number of elements assigned randomly, we could keep track of all of these assignments in a map and double-check that join is correct via double-checking that map in a loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xedin I did that here. I just generated it offline.

@gottesmm
Copy link
Contributor Author

I will fix @xedin 's suggestions in a follow on.

@gottesmm gottesmm merged commit ff6ee74 into swiftlang:main Oct 26, 2023
@gottesmm gottesmm deleted the pr-4c7e13d3cbc1677f17c72b86d9a02042e97eded1 branch October 26, 2023 17:58
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.

2 participants