Github Improve performance of git status check in `cargo package`. by ehuss · Pu...
source link: https://github.com/rust-lang/cargo/pull/9478
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
The check for a dirty repository during packaging/publishing is quite slow. It was calling status_file
for every packaged file, which is very expensive. I have a directory that had about 10,000 untracked files. Previously, cargo would hang for over 2 minutes without any output. With this PR, it finishes in 0.3 seconds.
The solution here is to collect the status information once, and then compare the package list against it.
One subtle point is that it does not use recurse_untracked_dirs
, and instead relies on a primitive starts_with
comparison, which I believe should be equivalent.
This still includes an inefficient n^2 algorithm, but I am too lazy to make a better approach.
I'm moderately confident this is pretty much the same as before (at least, all the scenarios I could think of).
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK