diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-04-01 16:40:45 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-04-15 14:00:17 +1000 |
| commit | 304a7be7a875e76a040bce0d1247d17d475e460a (patch) | |
| tree | 1c0ef2ed6d0fff3d3d627c25891471ef31377027 | |
| parent | 9cd61f025b1b92076e69a9ef2d9233325c7d8bdc (diff) | |
| download | rust-304a7be7a875e76a040bce0d1247d17d475e460a.tar.gz rust-304a7be7a875e76a040bce0d1247d17d475e460a.zip | |
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.
| -rw-r--r-- | src/librustc/dep_graph/graph.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index db81a9d826f..1ecc580d8c5 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -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), |
