Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable on-demand rustc incremental compilation
Summary: Users can now enable incremental compilation by running: ``` buck2 build -c rust.incremental=relative/path/to/target <TARGET> ``` This will generate an `incremental/<BUILD_MODE>/` directory which can be reused between builds. Since `rustc` is quite opinionated about incremental artifact hashing, file naming and placement, we enforce incremental compilation to run locally by skipping RE. ## Benchmarking (quick) From a few local experiments run builds with and without incremental compilation turned on after making minor code changes, I see *> 80%* reduction in build times when using incremental compilation: **example #1**: `//common/rust/tools/rust-expand:rust-expand` ``` |---------------------+-------------------+-------------------------| | Build type | 1st Build (clean) | 2nd Build (with change) | |---------------------+-------------------+-------------------------| | Without incremental | 9.2sec | 14.2sec | | With incremental | 15.2sec | 2.1sec | |---------------------+-------------------+-------------------------| ``` **example #2**: `//common/rust/tools/rustfix2:buck` ``` |---------------------+-------------------+-------------------------| | Build type | 1st Build (clean) | 2nd Build (with change) | |---------------------+-------------------+-------------------------| | Without incremental | 7.6sec | 3.4sec | | With incremental | 9sec | 0.72sec | |---------------------+-------------------+-------------------------| ``` For both examples above, 1st build gets run & timed like so: ``` for i in {1..5}; do buck2 clean && time buck2 build --show-full-output //common/rust/tools/rustfix2:buck; done ``` and 2nd build gets run & timed like so: ``` cd ~/fbcode for i in {1..5}; do sed -i 's/println!("some some something 1");/&\n println!("some some something 2");/' common/rust/tools/rustfix2/src/buck.rs && time buck2 build --show-full-output //common/rust/tools/rustfix2:buck; done ``` adding and removing `-c rust.incremental` to generate results with and without incremental compilation. Reviewed By: krallin Differential Revision: D38374692 fbshipit-source-id: 0f7412249da6e3dad2a381f0945e8cc8f9412065
- Loading branch information