Uh oh!
There was an error while loading. Please reload this page.
Avoid many CrateConfig clones. - #37161
Conversation
This commit changes `ExtCtx::cfg()` so it returns a `CrateConfig` reference instead of a clone. As a result, it also changes all of the `cfg()` callsites to explicitly clone... except one, because the commit also changes `macro_parser::parse()` to take `&CrateConfig`. This is good, because that function can be hot, and `CrateConfig` is expensive to clone. This change almost halves the number of heap allocations done by rustc for `html5ever` in rustc-benchmarks suite, which makes compilation 1.20x faster.
eddyb
commented
Oct 14, 2016
If we can't use references in some cases but the data is always immutable, why not wrap it in |
nnethercote
commented
Oct 14, 2016
I tried making it a |
eddyb
commented
Oct 14, 2016
I mean, either |
nnethercote
commented
Oct 14, 2016
I don't understand what you mean by this. Can you elaborate? Thanks. |
eddyb
commented
Oct 14, 2016
I mean that there's still many clones and some of them may contribute to expansion times in other crates. |
nnethercote
commented
Oct 14, 2016
Premature optimization, don't let perfect be the enemy of good, etc, etc. Let's see what @nrc thinks. |
eddyb
commented
Oct 14, 2016
Hey I thought the motto of Rust was "Don't let 'good enough' be the enemy of 'perfect'" 😆 |
nnethercote
commented
Oct 16, 2016
I know you are at least partly joking, but I will respond seriously: an uncompromising attitude like that makes sense for aspects of Rust's design as a language -- e.g. no compromise on memory safety -- but I don't think the same attitude is necessarily relevant or helpful when it comes to the compiler implementation. |
nrc
commented
Oct 18, 2016
bors
commented
Oct 18, 2016
📌 Commit 029dcee has been approved by |
eddyb
commented
Oct 18, 2016
@nrc This PR adds clone calls all over the place, using |
Avoid many CrateConfig clones. This commit changes `ExtCtx::cfg()` so it returns a `CrateConfig` reference instead of a clone. As a result, it also changes all of the `cfg()` callsites to explicitly clone... except one, because the commit also changes `macro_parser::parse()` to take `&CrateConfig`. This is good, because that function can be hot, and `CrateConfig` is expensive to clone. This change almost halves the number of heap allocations done by rustc for `html5ever` in rustc-benchmarks suite, which makes compilation 1.20x faster. r? @nrc
Avoid many CrateConfig clones. This commit changes `ExtCtx::cfg()` so it returns a `CrateConfig` reference instead of a clone. As a result, it also changes all of the `cfg()` callsites to explicitly clone... except one, because the commit also changes `macro_parser::parse()` to take `&CrateConfig`. This is good, because that function can be hot, and `CrateConfig` is expensive to clone. This change almost halves the number of heap allocations done by rustc for `html5ever` in rustc-benchmarks suite, which makes compilation 1.20x faster. r? @nrc
nnethercote
commented
Oct 27, 2016
@jseyfried ended up removing all the |
This commit changes
ExtCtx::cfg()so it returns aCrateConfigreference instead of a clone. As a result, it also changes all of the
cfg()callsites to explicitly clone... except one, because the commitalso changes
macro_parser::parse()to take&CrateConfig. This isgood, because that function can be hot, and
CrateConfigis expensiveto clone.
This change almost halves the number of heap allocations done by rustc
for
html5everin rustc-benchmarks suite, which makes compilation 1.20xfaster.
r? @nrc