-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Require that hop_to_executor eventually actually takes an executor #36643
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
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci please smoke test |
2a1e54c
to
0b2d4a5
Compare
pushing scopes for various tracking objects as needed.
300d9bf
to
4536ef1
Compare
@swift-ci Please test |
Build failed |
Build failed |
The comment in LowerHopToActor explains the design here. We want SILGen to emit hops to actors, ignoring executors, because it's easier to fully optimize in a world where deriving an executor is a non-trivial operation. But we also want something prior to IRGen to lower the executor derivation because there are useful static optimizations we can do, such as doing the derivation exactly once on a dominance path and strength-reducing the derivation (e.g. exploiting static knowledge that an actor is a default actor). There are probably phase-ordering problems with doing this so late, but hopefully they're restricted to situations like actors that share an executor. We'll want to optimize that eventually, but in the meantime, this unblocks the executor work.
4536ef1
to
4f6f8b3
Compare
@swift-ci Please test |
Build failed |
@swift-ci Please smoke test Linux |
@swift-ci Please test Linux |
@eeckstein Please let me know what you think about the new implementation. We should be able to use this for CSE as well, although I didn't try. |
Build failed |
@swift-ci Please test Linux |
Build failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks much better now.
Basically LGTM. I just have a few suggestions for improvements.
void runInDominanceOrderWithScopes(DominanceInfo *dominance, Fn &&fn, | ||
Trackers &...trackers) { | ||
using TrackingStackNode = TrackingScopes<Trackers...>; | ||
llvm::SmallVector<std::unique_ptr<TrackingStackNode>, 8> trackingStack; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The maximum size of trackingStack is the number of blocks in the function. If you pre-allocate (e.g. reserve) an array of TrackingStackNode (not pointers!) with this size then you don't need to alloc a new StrackingStackNode for each block. Maybe just use a plain old C array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try to optimize this so that it doesn't require heap-allocation, sure. But this is already better than CSE, FWIW.
@swift-ci Please test Linux |
Currently the SIL
hop_to_executor
instruction can take either aBuiltin.Executor
or an actor reference. The runtime operation requires an executor, and custom executors mean that the distinction is important. We want to be able to optimize executor hops, including eliminating the actor-to-executor derivation, but we also want to be able to statically optimize the executor lowerings that we actually have to do.Thread this needle by doing the lowering in a pass that runs after
hop_to_executor
optimization but before IRGen.