mirror of
https://github.com/rust-lang/cargo
synced 2024-08-27 19:29:21 +00:00
Adjust git::fetch() progress bar to deal with gitoxide-specifics
The `git2` implementation can leverage that `git2` provides a consistent view on the objects to be index, so it looks like 33% of the time is spent receiving objects, and the rest of the time is used resolving them. In `gitoxide`, there are two distinct phases and these are exposed by the way we obtain progress for two separate phases. We have to do some math to renormalize those to a single, continuous progress by mapping the values for 'amount of objects' to the first half and second half of the progress bar respectively. This has the advantage of having the first phase (receiving objects) end at 50% and the second phase (resolving deltas) at 100%.
This commit is contained in:
parent
8ef74afabc
commit
6e96095cfc
|
@ -30,8 +30,8 @@ filetime = "0.2.9"
|
||||||
flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] }
|
flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] }
|
||||||
git2 = "0.16.0"
|
git2 = "0.16.0"
|
||||||
git2-curl = "0.17.0"
|
git2-curl = "0.17.0"
|
||||||
gix = { version = "0.38.0", default-features = false, features = ["blocking-http-transport-curl", "progress-tree"] }
|
gix = { version = "0.39.0", default-features = false, features = ["blocking-http-transport-curl", "progress-tree"] }
|
||||||
gix-features-for-configuration-only = { version = "0.27.0", package = "gix-features", features = [ "parallel" ] }
|
gix-features-for-configuration-only = { version = "0.28.0", package = "gix-features", features = [ "parallel" ] }
|
||||||
glob = "0.3.0"
|
glob = "0.3.0"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
hmac = "0.12.1"
|
hmac = "0.12.1"
|
||||||
|
|
|
@ -96,13 +96,14 @@ fn translate_progress_to_bar(
|
||||||
tasks.iter().find_map(|(_, t)| cb(t))
|
tasks.iter().find_map(|(_, t)| cb(t))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NUM_PHASES: usize = 2; // indexing + delta-resolution, both with same amount of objects to handle
|
||||||
if let Some(objs) = find_in(&tasks, |t| progress_by_id(resolve_objects, t)) {
|
if let Some(objs) = find_in(&tasks, |t| progress_by_id(resolve_objects, t)) {
|
||||||
// Resolving deltas.
|
// Resolving deltas.
|
||||||
let objects = objs.step.load(Ordering::Relaxed);
|
let objects = objs.step.load(Ordering::Relaxed);
|
||||||
let total_objects = objs.done_at.expect("known amount of objects");
|
let total_objects = objs.done_at.expect("known amount of objects");
|
||||||
let msg = format!(", ({objects}/{total_objects}) resolving deltas");
|
let msg = format!(", ({objects}/{total_objects}) resolving deltas");
|
||||||
|
|
||||||
progress_bar.tick(objects, total_objects, &msg)?;
|
progress_bar.tick(total_objects + objects, total_objects * NUM_PHASES, &msg)?;
|
||||||
} else if let Some((objs, read_pack)) =
|
} else if let Some((objs, read_pack)) =
|
||||||
find_in(&tasks, |t| progress_by_id(read_pack_bytes, t)).and_then(|read| {
|
find_in(&tasks, |t| progress_by_id(read_pack_bytes, t)).and_then(|read| {
|
||||||
find_in(&tasks, |t| progress_by_id(delta_index_objects, t))
|
find_in(&tasks, |t| progress_by_id(delta_index_objects, t))
|
||||||
|
@ -122,7 +123,7 @@ fn translate_progress_to_bar(
|
||||||
let (rate, unit) = human_readable_bytes(counter.rate() as u64);
|
let (rate, unit) = human_readable_bytes(counter.rate() as u64);
|
||||||
let msg = format!(", {rate:.2}{unit}/s");
|
let msg = format!(", {rate:.2}{unit}/s");
|
||||||
|
|
||||||
progress_bar.tick(objects, total_objects, &msg)?;
|
progress_bar.tick(objects, total_objects * NUM_PHASES, &msg)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue