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

cargo waits on package cache lock when my crate has 0 dependencies #11924

Open
matthiaskrgr opened this issue Apr 2, 2023 · 3 comments
Open
Labels
A-caching Area: caching of dependencies, repositories, and build artifacts C-bug Category: bug P-low Priority: Low Performance Gotta go fast! S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@matthiaskrgr
Copy link
Member

Problem

It seems that cargo is waiting for the lock on the package cache during cargo check, even if I have 0 dependencies stated in my Cargo.toml and we could theoretically build right away.

Steps

  1. cargo new myproj
  2. run cargo update on a large repo (i.e. servo)
  3. at the same time cargo check in myproj
    => Blocking waiting for file lock on package cache although myproj has 0 dependencies.

Possible Solution(s)

Skip looking into the cache entirely if we don't have any dependencies specified in Cargo.toml?

Notes

No response

Version

cargo 1.70.0-nightly (0e474cfd7 2023-03-31)
release: 1.70.0-nightly
commit-hash: 0e474cfd7b16b018cf46e95da3f6a5b2f1f6a9e7
commit-date: 2023-03-31
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:OpenSSL/1.1.1q)
os: Manjaro 22.1.0 (Talos) [64-bit
@matthiaskrgr matthiaskrgr added the C-bug Category: bug label Apr 2, 2023
@weihanglo
Copy link
Member

I feel like it is a niche use case, and a bit error-prone to implement this, since the acquisition of package cache lock occurs in multiple different places. It's also not easy to understand where a lock is needed by just looking into the piece of code here. That said, it is a nice-to-have optimization, just not that urgent.

@weihanglo weihanglo added A-caching Area: caching of dependencies, repositories, and build artifacts Performance Gotta go fast! labels Apr 12, 2023
@epage
Copy link
Contributor

epage commented Apr 12, 2023

The cargo-script workflow could put more of an emphasis the overhead for cargo run with warm caches and without any dependencies.

@matthiaskrgr
Copy link
Member Author

Hm, my current usecase is that I grab a random rs file, copy it into into main.rs of a dummy crate I created with cargo new (so no deps) and then run cargo miri run/test on it.
All this can happen on several files at a time, in parallel.
https://github.com/matthiaskrgr/icemaker/blob/master/src/run_commands.rs#L704
Luckily the locking of the cargo home does not seem to be that much of a bottle neck though..

I'm not sure if the cargo-script workflow can do anything for miri right now 😅

@weihanglo weihanglo added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. P-low Priority: Low labels Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-caching Area: caching of dependencies, repositories, and build artifacts C-bug Category: bug P-low Priority: Low Performance Gotta go fast! S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

3 participants