sfackler / cargo-tree

Apache License 2.0
529 stars 39 forks source link

Improve compile time #90

Closed tesuji closed 4 years ago

tesuji commented 4 years ago

According to measurement on my machine, compilation time go from 45.8s to 25.4s. More infomation in cargo-timing file: https://gist.github.com/lzutao/4b1a3709d150a6c746fb9b93dcd80076

sfackler commented 4 years ago

Does cargo install respect this part of the manifest?

tesuji commented 4 years ago

Test locally with cargo -Ztimings install --path ., it seems so. I updated the gist link with new result of cargo install.

ehuss commented 4 years ago

You might want to consider using this instead of listing explicit packages.

[profile.release.build-override]
opt-level = 0

Also beware, this sets the msrv to 1.41.

tesuji commented 4 years ago

this sets the msrv to 1.41.

@sfackler set CI to nightly. So this shouldn't be problem?

Does build-override make crates have build.rs (for example FFI crates) no optimization even in release build? I cannot tell when looking at https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#overrides

ehuss commented 4 years ago

Does build-override make build.rs (which FFI crates often be) no optimization even in release build?

I'm not sure I understand the question. The build script and all of its dependencies will be built with opt-level=0. Running the build script will still set the OPT_LEVEL environment variable to 2, build-override does not affect that.

tesuji commented 4 years ago

Sorry for confusing. I was asking that does build-override make FFI crates, which often have build.rs, non opimized in release build?

ehuss commented 4 years ago

Ah, no. The crate itself is unaffected and will use opt-level=2. Cargo doesn't know if something is an ffi crate or not. build-override only affects compilation of the build.rs script itself (and proc macros).

tesuji commented 4 years ago

Thanks for explanation. I was misunderstanding that.

sfackler commented 4 years ago

Neat, thanks!