Don't check out the crates.io index locally#4026
Conversation
|
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
|
r? @matklad |
src/cargo/sources/registry/remote.rs
Outdated
There was a problem hiding this comment.
What guarantees that tree will be destroyed first? Unspecified drop order? In that case, maybe this is a good case for ManuallyDrop? Or is that not yet usable in cargo due to instability?
There was a problem hiding this comment.
@alexcrichton ping. Should there be a crate for this sort of stuff? https://github.com/Kimundi/owning-ref-rs perhaps?
There was a problem hiding this comment.
Oh sorry missed this! Yes the unspecified drop order is what guarantees this. Lots of projects are relying on this so I don't think it's necessary to go out of the way and use ManuallyDrop, and yeah I'd also prefer to keep Cargo on stable.
@matklad unfortunately that crate won't help as it's targeted at Rust pointers, whereas here it's all phantom lifetimes through libgit2 :(
There was a problem hiding this comment.
Since it's in an Option, you could explicitly take() it first in an impl Drop for RemoteRegistry.
There was a problem hiding this comment.
Indeed! I'll do that.
|
☔ The latest upstream changes (presumably #4024) made this pull request unmergeable. Please resolve the merge conflicts. |
6bbd534 to
dcbbfab
Compare
src/cargo/sources/registry/index.rs
Outdated
There was a problem hiding this comment.
Ideally we should not swallow utf8-decoding errors here.
There was a problem hiding this comment.
Or are we planing to switch to binary format some day?
There was a problem hiding this comment.
Nah this was mostly inspired from discussion on the RFC about schema versioning. I have no plans to break this personally, but it seems reasonable to be somewhat defensive about future changes to the index just for maximal flexibility of future cargo's implementation.
There was a problem hiding this comment.
I'm totally ok with self.parse_registry_package(line).ok(), it's only str::from_utf8(b).ok() that feels overly defensive.
src/cargo/sources/registry/local.rs
Outdated
There was a problem hiding this comment.
Why not path: &Path? We convert str to Path both for Local and Remote registry anyway. Those slashes format!("{}/{}/{}", &fs_name[0..2], &fs_name[2..4], fs_name) make me nervous :)
There was a problem hiding this comment.
And do we need root here? Can't we reconstruct it from index_path?
There was a problem hiding this comment.
Ah my thinking of passing in root is that index_path returns a Filesystem which is an "unlocked path", but here we've always got a locked path (locked elsewhere) so looking at a Path is proof of that.
I was originally unsure what would happen if we take a \-separated path when we go down to libgit2, I'm not sure if it handles internally the slash differences. Only one way to find out!
src/cargo/sources/registry/remote.rs
Outdated
There was a problem hiding this comment.
Why do we need LazyCell on top of RefCell? LazyCell is useful to return &T and not Ref<T>, but we are returning a Ref anyway, so just RefCell<Option<git2::Tree<'static>>> should be enough levels of indirection...
There was a problem hiding this comment.
Hm excellent point!
1ea815a to
a4e850f
Compare
|
Pushed some updates |
src/cargo/sources/registry/remote.rs
Outdated
There was a problem hiding this comment.
Looks like easy and repo could use LazyCell::get_or_try_init instead of manually unwrapping things.
There was a problem hiding this comment.
Aha yes indeed! I thought I tried that but thanks for catching
e51d729 to
c2e82c2
Compare
|
Updated |
|
LGTM, though there was seemingly legitimate failure on appveyor on the previous build. |
7ff4bca to
b7414ce
Compare
|
Bah looks like libgit2 cares about \ vs / |
|
@bors: r=matklad |
|
📌 Commit b7414ce has been approved by |
|
🔒 Merge conflict |
|
☔ The latest upstream changes (presumably #4032) made this pull request unmergeable. Please resolve the merge conflicts. |
This commit moves working with the crates.io index to operating on the git object layers rather than actually literally checking out the index. This is aimed at two different goals: * Improving the on-disk file size of the registry * Improving cloning times for the registry as the index doesn't need to be checked out The on disk size of my `registry` folder of a fresh check out of the index went form 124M to 48M, saving a good chunk of space! The entire operation took about 0.6s less on a Unix machine (out of 4.7s total for current Cargo). On Windows, however, the clone operation went from 11s to 6.7s, a much larger improvement! Closes rust-lang#4015
b7414ce to
15cc376
Compare
|
@bors: r=matklad |
|
📌 Commit 15cc376 has been approved by |
Don't check out the crates.io index locally This commit moves working with the crates.io index to operating on the git object layers rather than actually literally checking out the index. This is aimed at two different goals: * Improving the on-disk file size of the registry * Improving cloning times for the registry as the index doesn't need to be checked out The on disk size of my `registry` folder of a fresh check out of the index went form 124M to 48M, saving a good chunk of space! The entire operation took about 0.6s less on a Unix machine (out of 4.7s total for current Cargo). On Windows, however, the clone operation went from 11s to 6.7s, a much larger improvement! Closes #4015
|
☀️ Test successful - status-appveyor, status-travis |
Allows for seamless ransition for when rust-lang/cargo#4026 lands Closes #32
This commit moves working with the crates.io index to operating on the git
object layers rather than actually literally checking out the index. This is
aimed at two different goals:
checked out
The on disk size of my
registryfolder of a fresh check out of the index wentform 124M to 48M, saving a good chunk of space! The entire operation took about
0.6s less on a Unix machine (out of 4.7s total for current Cargo). On Windows,
however, the clone operation went from 11s to 6.7s, a much larger improvement!
Closes #4015