Skip to content

Commit

Permalink
Avoid UncanonicalizedIter during prefetch
Browse files Browse the repository at this point in the history
It's not really necessary. It's okay if it takes us slightly longer to
generate an error.
  • Loading branch information
Jon Gjengset committed Nov 26, 2020
1 parent 8ccaf4f commit 9ad0ff6
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/cargo/sources/registry/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ impl<'s> Iterator for UncanonicalizedIter<'s> {
return None;
}

// TODO:
// This implementation can currently generate paths like en/v-/env_logger,
// which doesn't _seem_ like a useful candidate to test?
let ret = Some(
self.input
.chars()
Expand Down Expand Up @@ -494,15 +497,16 @@ impl<'cfg> RegistryIndex<'cfg> {

// Seed the prefetching with the root dependencies.
for dep in deps {
let raw_path = relative(&*dep.package_name());
for relative in UncanonicalizedIter::new(&raw_path).take(1024) {
load.prefetch(
root,
&Path::new(&relative),
dep.package_name(),
dep.version_req(),
)?;
}
let relative = relative(&*dep.package_name());
// NOTE: We do not use UncanonicalizedIter here or below because if the user gave a
// misspelling, it's fine if we don't prefetch their misspelling. The resolver will be
// a bit slower, but then give them an error.
load.prefetch(
root,
&Path::new(&relative),
dep.package_name(),
dep.version_req(),
)?;
}

// Now, continuously iterate by walking dependencies we've loaded and fetching the index
Expand Down Expand Up @@ -567,17 +571,13 @@ impl<'cfg> RegistryIndex<'cfg> {
continue;
}

let raw_path = relative(&*dep.package_name());
for relative in UncanonicalizedIter::new(&raw_path).take(1024) {
// NOTE: Many of these prefetches will "miss", but that's okay.
// They're going to be pipelined anyway.
load.prefetch(
root,
Path::new(&relative),
dep.package_name(),
dep.version_req(),
)?;
}
let relative = relative(&*dep.package_name());
load.prefetch(
root,
Path::new(&relative),
dep.package_name(),
dep.version_req(),
)?;
}
}
}
Expand Down

0 comments on commit 9ad0ff6

Please sign in to comment.