Skip to content

Commit a21e95e

Browse files
committed
Auto merge of #137563 - FractalFir:dep_graph_cap, r=<try>
[Perf experiment] Changed TaskDeps to start with preallocated with 1024 capacity This is a tiny change that makes `TaskDeps::read_set` start preallocated with capacity for 1024 elements(4096 bytes). Somewhat annoyingly, `HashSet::with_capacity` requires the hasher to implement `RandomState`. Since `FxHash` does not implement `RandomState`, I had to use `HashSet::with_capacity_and_hasher`, which required re-exporting `FxBuildHasher` in `rustc_data_structures`. From local profiling, it looks like `TaskDeps::read_set` is one of the most-often resized hash-sets in `rustc`. Local perf runs indicate this is a small perf improvement(without any regressions). There is also no significant RSS increase(the RSS changes are noisy and cancel themselves out almost entirely). Still, since the local and CI results can differ, I'll do a CI perf run before this PR can be reviewed. `@bors` try `@rust-timer` queue
2 parents 96cfc75 + e100fd4 commit a21e95e

File tree

1 file changed

+1
-2
lines changed
  • compiler/rustc_query_system/src/dep_graph

1 file changed

+1
-2
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1299,12 +1299,11 @@ impl Default for TaskDeps {
12991299
#[cfg(debug_assertions)]
13001300
node: None,
13011301
reads: EdgesVec::new(),
1302-
read_set: FxHashSet::default(),
1302+
read_set: FxHashSet::with_capacity_and_hasher(128, Default::default()),
13031303
phantom_data: PhantomData,
13041304
}
13051305
}
13061306
}
1307-
13081307
// A data structure that stores Option<DepNodeColor> values as a contiguous
13091308
// array, using one u32 per entry.
13101309
struct DepNodeColorMap {

0 commit comments

Comments
 (0)