Skip to content

Commit 1edb01b

Browse files
committed
Auto merge of #59626 - nnethercote:DepGraph-1.02x, r=Zoxc
Reduce the `DepNode` pre-allocation ratio. A code size of increase of 15% is overly generous. 2% is more realistic. This change reduces peak memory size by 20+ MiB on some workloads. r? @Zoxc
2 parents a55f6be + 304a7be commit 1edb01b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/librustc/dep_graph/graph.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,9 @@ impl CurrentDepGraph {
992992

993993
// Pre-allocate the dep node structures. We over-allocate a little so
994994
// that we hopefully don't have to re-allocate during this compilation
995-
// session.
996-
let new_node_count_estimate = (prev_graph_node_count * 115) / 100;
995+
// session. The over-allocation is 2% plus a small constant to account
996+
// for the fact that in very small crates 2% might not be enough.
997+
let new_node_count_estimate = (prev_graph_node_count * 102) / 100 + 200;
997998

998999
CurrentDepGraph {
9991000
data: IndexVec::with_capacity(new_node_count_estimate),

0 commit comments

Comments
 (0)