![](/style/images/good.png)
![](/style/images/bad.png)
Optimization: parse manifest only once by mkeeter · Pull Request #2898 · rust-la...
source link: https://github.com/rust-lang/rustup/pull/2898
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
I was building a project which invoked cargo
multiple times, and noticed that a no-op build (i.e. a build with no local changes) was surprisingly slow.
Generating a flamegraph of one cargo
call, I noticed the following:
About half the work is done in Manifestation::load_manifest
, which is called twice to parse the same 700K TOML file (here and here).
This PR adds a new struct
in toolchain.rs
which encapsulates this parsed manifest plus other relevant data. This struct
is then used in config.rs
to eliminate the double-parsing.
I also use this struct
to clean up duplicate code in toolchain.rs
, e.g. this comment:
// Overlapping code with get_manifest :/.
I see a 15-25% speedup in a no-op build, depending on the project!
- Tests all pass (at least on my machine!)
-
No new
clippy
lints (there are a few pre-existing lints in areas I haven't touched) -
rustfmt
run
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK