Skip to content

Commit 61ba60c

Browse files
authored
[orc] Avoid pathological propogation order (#107488)
In certain pathological object files we were getting extremely slow linking because we were repeatedly propogating dependencies to the same blocks instead of accumulating as many changes as possible. Change the order of iteration so that we go through every node in the worklist before returning to any previous node, reducing the number of expensive dependency iterations. In practice, this took one case from 60 seconds to 2 seconds. Note: the performance is still non-deterministic, because the block order itself is non-deterministic. rdar://133734391
1 parent 4af249f commit 61ba60c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
605605
bool DependenciesChanged = true;
606606
};
607607
DenseMap<Block *, BlockInfo> BlockInfos;
608-
SmallVector<Block *> WorkList;
608+
std::deque<Block *> WorkList;
609609

610610
// Pre-allocate map entries. This prevents any iterator/reference
611611
// invalidation in the next loop.
@@ -637,7 +637,8 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
637637

638638
// Propagate block-level dependencies through the block-dependence graph.
639639
while (!WorkList.empty()) {
640-
auto *B = WorkList.pop_back_val();
640+
auto *B = WorkList.back();
641+
WorkList.pop_back();
641642

642643
auto &BI = BlockInfos[B];
643644
assert(BI.DependenciesChanged &&
@@ -650,7 +651,7 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
650651
DependantBI.Dependencies.insert(Dependency).second)
651652
if (!DependantBI.DependenciesChanged) {
652653
DependantBI.DependenciesChanged = true;
653-
WorkList.push_back(Dependant);
654+
WorkList.push_front(Dependant);
654655
}
655656
}
656657
}

0 commit comments

Comments
 (0)