-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Describe the problem you are trying to solve
When only a single small crate of a large crate graph is recompiled, cargo has a significant overhead trying to parse all Cargo.toml files and resolve all dependencies. On Bevy I measured an overhead of 28% when doing touch examples/game/breakout.rs; cargo build --example breakout after bevyengine/bevy#791.
Describe the solution you'd like
I would like the overhead of cargo to be reduced. This could be done by optimizing the relevant functions or by for example adding a binary cache for a specific cargo invocation that contains the build plan (I think it is called that way) of everything that cargo will do. This binary cache could be invalidated on any Cargo.toml change or change to the cargo arguments. In case of argument change it would be preferable to keep the old cache around though, as rust-analyzer may run cargo check and the user cargo run.
Notes
By the way I noticed that the new resolver is a bit slower than the old one:
$ hyperfine --warmup 10 --runs 100 "touch examples/game/breakout.rs && cargo build --example breakout" "touch examples/game/breakout.rs && cargo build -Zfeatures=all -Zpackage-features --example breakout"
Benchmark #1: touch examples/game/breakout.rs && cargo build --example breakout
Time (mean ± σ): 678.8 ms ± 21.5 ms [User: 573.7 ms, System: 160.8 ms]
Range (min … max): 668.1 ms … 812.3 ms 100 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Benchmark #2: touch examples/game/breakout.rs && cargo build -Zfeatures=all -Zpackage-features --example breakout
Time (mean ± σ): 690.2 ms ± 20.4 ms [User: 582.6 ms, System: 164.8 ms]
Range (min … max): 683.3 ms … 891.4 ms 100 runs
Warning: The first benchmarking run for this command was significantly slower than the rest (891.4 ms). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.
Summary
'touch examples/game/breakout.rs && cargo build --example breakout' ran
1.02 ± 0.04 times faster than 'touch examples/game/breakout.rs && cargo build -Zfeatures=all -Zpackage-features --example breakout'
