Skip to content

Commit 67bc695

Browse files
authored
Rollup merge of rust-lang#64420 - nnethercote:inline-mark_neighbours_as_waiting_from, r=Mark-Simulacrum
Inline `mark_neighbours_as_waiting_from`. This function is very hot, doesn't get inlined because it's recursive, and the function calls are significant. This commit splits it into inlined and uninlined variants, and uses the inlined variant for the hot call site. This wins several percent on a few benchmarks. r? @nikomatsakis
2 parents f3e8227 + a2261ad commit 67bc695

File tree

1 file changed

+13
-4
lines changed
  • src/librustc_data_structures/obligation_forest

1 file changed

+13
-4
lines changed

src/librustc_data_structures/obligation_forest/mod.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -559,13 +559,20 @@ impl<O: ForestObligation> ObligationForest<O> {
559559
trace
560560
}
561561

562-
#[inline]
563-
fn mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
562+
// This always-inlined function is for the hot call site.
563+
#[inline(always)]
564+
fn inlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
564565
for dependent in node.parent.iter().chain(node.dependents.iter()) {
565566
self.mark_as_waiting_from(&self.nodes[dependent.get()]);
566567
}
567568
}
568569

570+
// This never-inlined function is for the cold call site.
571+
#[inline(never)]
572+
fn uninlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
573+
self.inlined_mark_neighbors_as_waiting_from(node)
574+
}
575+
569576
/// Marks all nodes that depend on a pending node as `NodeState::Waiting`.
570577
fn mark_as_waiting(&self) {
571578
for node in &self.nodes {
@@ -576,7 +583,8 @@ impl<O: ForestObligation> ObligationForest<O> {
576583

577584
for node in &self.nodes {
578585
if node.state.get() == NodeState::Pending {
579-
self.mark_neighbors_as_waiting_from(node);
586+
// This call site is hot.
587+
self.inlined_mark_neighbors_as_waiting_from(node);
580588
}
581589
}
582590
}
@@ -588,7 +596,8 @@ impl<O: ForestObligation> ObligationForest<O> {
588596
NodeState::Pending | NodeState::Done => {},
589597
}
590598

591-
self.mark_neighbors_as_waiting_from(node);
599+
// This call site is cold.
600+
self.uninlined_mark_neighbors_as_waiting_from(node);
592601
}
593602

594603
/// Compresses the vector, removing all popped nodes. This adjusts

0 commit comments

Comments
 (0)