Skip to content

Commit

Permalink
Auto merge of #59626 - nnethercote:DepGraph-1.02x, r=Zoxc
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 15, 2019
2 parents a55f6be + 304a7be commit 1edb01b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,9 @@ impl CurrentDepGraph {

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

CurrentDepGraph {
data: IndexVec::with_capacity(new_node_count_estimate),
Expand Down

0 comments on commit 1edb01b

Please sign in to comment.