Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indexmap is rebuilt on every cargo run #123

Closed
alin-at-dfinity opened this issue Jun 1, 2020 · 5 comments · Fixed by #124
Closed

indexmap is rebuilt on every cargo run #123

alin-at-dfinity opened this issue Jun 1, 2020 · 5 comments · Fixed by #124

Comments

@alin-at-dfinity
Copy link

alin-at-dfinity commented Jun 1, 2020

From what I can tell, the changes in #106 caused one of our CI jobs' run times to shoot up from ~23 minutes (while depending on indexmap 1.1.0) to 1 1/2 - 2 hours (about 4x, while depending on indexmap 1.3.2).

Due to the shortcomings of cargo we need to run it 4 times in succession to cover all bases:

$ cargo build --release --all-targets      # Build production code
$ cargo test --no-run --release            # Build tests and doc tests
$ cargo test --no-run --release --benches  # Build benchmarks
$ cargo test --release                     # Run tests and doc tests

Normally this is not an issue, as the cargo build at the top usually builds everything, the next two are no-ops, and the last one again doesn't need to build anything, only run the tests. But after bumping indexmap to 1.3.2 in Cargo.lock, suddenly each of those cargo commands first starts rebuilding indexmap and then everything that depends on it, essentially doing the exact same thing 4 times.

AFAICT that is because of the use of autocfg in build.rs. Every time cargo is run, it thinks indexmap has been modified and rebuilds it. Which in turn causes everything that depends on it to be rebuilt. Although nothing at all has changed.

I don't have a solution and I've already spent way too much time tracking this down and finding a workaround (rolled back indexmap to 1.2.0), but it would be great if you could find a way to convince cargo that nothing has changed and it doesn't need to rebuild indexmap every single time.

(BTW, this is not only an issue for CI, any local build or test run will also start by rebuilding indexmap and go from there.)

@cuviper
Copy link
Member

cuviper commented Jun 1, 2020

Are you perhaps using --remap-path-prefix? We realized in rust-num/num-traits#139 that this is reflected in file!(), which makes autocfg::rerun_path(file!()) behave poorly since that path never actually exists from cargo's perspective. We should just use "build.rs" there.

@alin-at-dfinity
Copy link
Author

We do use Nix for reproducible builds, so it may well be using --remap-path-prefix under the cover. But I'm not closely familiar with Nix.

@pikajude
Copy link

pikajude commented Jun 1, 2020

Yeah we do use --remap-path-prefix

@bluss bluss closed this as completed in #124 Jun 1, 2020
@bluss
Copy link
Member

bluss commented Jun 2, 2020

Thanks for providing so much good information in the bug report.

@alin-at-dfinity
Copy link
Author

FYI, bumping the dependency to indexmap 1.4.0 appears to have fixed the issue for us.

Thanks a lot for the quick fix (and point release).

Nemo157 added a commit to Nemo157/docs.rs that referenced this issue Sep 25, 2020
Avoids rebuilding every time (indexmap-rs/indexmap#123)
jyn514 pushed a commit to rust-lang/docs.rs that referenced this issue Sep 25, 2020
Avoids rebuilding every time (indexmap-rs/indexmap#123)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants