Skip to content

Commit 891a061

Browse files
committed
add more tasks to gather a little more information
1 parent 4cef57d commit 891a061

File tree

6 files changed

+196
-125
lines changed

6 files changed

+196
-125
lines changed

gitoxide-core/src/corpus/engine.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,38 +71,37 @@ impl Engine {
7171
dry_run: bool,
7272
) -> anyhow::Result<()> {
7373
let start = Instant::now();
74-
let task_progress = &mut self.state.progress;
75-
task_progress.set_name("run");
76-
task_progress.init(Some(tasks.len()), gix::progress::count("tasks"));
74+
let repo_progress = &mut self.state.progress;
7775
let threads = gix::parallel::num_threads(threads);
7876
let db_path = self.con.path().expect("opened from path on disk").to_owned();
79-
for (task_id, task) in tasks {
77+
'tasks_loop: for (task_id, task) in tasks {
8078
let task_start = Instant::now();
81-
let mut repo_progress = task_progress.add_child(format!("run '{}'", task.short_name));
79+
let task_info = format!("run '{}'", task.short_name);
80+
repo_progress.set_name(task_info.clone());
81+
repo_progress.init(Some(repos.len()), gix::progress::count("repos"));
8282
if task.execute_exclusive || threads == 1 || dry_run {
8383
if dry_run {
84-
task_progress.set_name("WOULD run");
84+
repo_progress.set_name("WOULD run");
8585
for repo in &repos {
86-
task_progress.info(format!(
86+
repo_progress.info(format!(
8787
"{}",
8888
repo.path
8989
.strip_prefix(corpus_path)
9090
.expect("corpus contains repo")
9191
.display()
9292
));
93-
task_progress.inc();
93+
repo_progress.inc();
9494
}
95-
task_progress.info(format!("with {} tasks", tasks.len()));
95+
repo_progress.info(format!("with {} tasks", tasks.len()));
9696
for (_, task) in tasks {
97-
task_progress.info(format!("task '{}' ({})", task.description, task.short_name))
97+
repo_progress.info(format!("task '{}' ({})", task.description, task.short_name))
9898
}
99-
continue;
99+
break 'tasks_loop;
100100
}
101-
repo_progress.init(Some(repos.len()), gix::progress::count("repos"));
102101
let mut run_progress = repo_progress.add_child("set later");
103102
let (_guard, current_id) = corpus::trace::override_thread_subscriber(
104103
db_path.as_str(),
105-
self.state.trace_to_progress.then(|| task_progress.add_child("trace")),
104+
self.state.trace_to_progress.then(|| repo_progress.add_child("trace")),
106105
self.state.reverse_trace_lines,
107106
)?;
108107

@@ -136,7 +135,9 @@ impl Engine {
136135
repo_progress.show_throughput(task_start);
137136
} else {
138137
let counter = repo_progress.counter();
139-
let repo_progress = gix::threading::OwnShared::new(gix::threading::Mutable::new(repo_progress));
138+
let repo_progress = gix::threading::OwnShared::new(gix::threading::Mutable::new(
139+
repo_progress.add_child("will be changed"),
140+
));
140141
gix::parallel::in_parallel_with_slice(
141142
&mut repos,
142143
Some(threads),
@@ -194,9 +195,9 @@ impl Engine {
194195
gix::threading::lock(&repo_progress).show_throughput(task_start);
195196
}
196197

197-
task_progress.inc();
198+
repo_progress.inc();
198199
}
199-
task_progress.show_throughput(start);
200+
repo_progress.show_throughput(start);
200201
Ok(())
201202
}
202203

gitoxide-core/src/corpus/run.rs

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::corpus;
22
use crate::corpus::{Run, Task};
3+
use crate::pack::verify::Algorithm;
34
use std::path::Path;
45
use std::sync::atomic::AtomicBool;
56

@@ -32,12 +33,26 @@ pub(crate) trait Execute {
3233
) -> anyhow::Result<()>;
3334
}
3435

35-
pub(crate) static ALL: &[Task] = &[Task {
36-
short_name: "OPNR",
37-
description: "open repository (isolated)",
38-
execute_exclusive: false,
39-
execute: &OpenRepo,
40-
}];
36+
pub(crate) static ALL: &[Task] = &[
37+
Task {
38+
short_name: "OPNR",
39+
description: "open repository (isolated)",
40+
execute_exclusive: false,
41+
execute: &OpenRepo,
42+
},
43+
Task {
44+
short_name: "POCN",
45+
description: "packed object count",
46+
execute_exclusive: false,
47+
execute: &CountPackedObjects,
48+
},
49+
Task {
50+
short_name: "VERI",
51+
description: "verify object database",
52+
execute_exclusive: true,
53+
execute: &VerifyOdb,
54+
},
55+
];
4156

4257
struct OpenRepo;
4358

@@ -53,3 +68,46 @@ impl Execute for OpenRepo {
5368
Ok(())
5469
}
5570
}
71+
72+
struct CountPackedObjects;
73+
74+
impl Execute for CountPackedObjects {
75+
fn execute(
76+
&self,
77+
repo: &Path,
78+
_progress: &mut corpus::engine::ProgressItem,
79+
_threads: Option<usize>,
80+
_should_interrupt: &AtomicBool,
81+
) -> anyhow::Result<()> {
82+
let repo = gix::open_opts(repo, gix::open::Options::isolated())?;
83+
repo.objects.packed_object_count()?;
84+
Ok(())
85+
}
86+
}
87+
88+
struct VerifyOdb;
89+
90+
impl Execute for VerifyOdb {
91+
fn execute(
92+
&self,
93+
repo: &Path,
94+
progress: &mut corpus::engine::ProgressItem,
95+
threads: Option<usize>,
96+
should_interrupt: &AtomicBool,
97+
) -> anyhow::Result<()> {
98+
let repo = gix::open_opts(repo, gix::open::Options::isolated())?;
99+
crate::repository::verify::integrity(
100+
repo,
101+
std::io::sink(),
102+
progress,
103+
should_interrupt,
104+
crate::repository::verify::Context {
105+
output_statistics: None,
106+
thread_limit: threads,
107+
verify_mode: Default::default(),
108+
algorithm: Algorithm::LessTime,
109+
},
110+
)?;
111+
Ok(())
112+
}
113+
}

gix-index/src/extension/tree/verify.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl Tree {
111111
}
112112
Ok(entries.into())
113113
}
114+
let _span = gix_features::trace::coarse!("gix_index::extension::Tree::verify()");
114115

115116
if !self.name.is_empty() {
116117
return Err(Error::RootWithName {

gix-index/src/file/verify.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub use error::Error;
2323
impl File {
2424
/// Verify the integrity of the index to assure its consistency.
2525
pub fn verify_integrity(&self) -> Result<(), Error> {
26+
let _span = gix_features::trace::coarse!("gix_index::File::verify_integrity()");
2627
let checksum = self.checksum.ok_or(Error::NoChecksum)?;
2728
let num_bytes_to_hash = self.path.metadata()?.len() - checksum.as_bytes().len() as u64;
2829
let should_interrupt = AtomicBool::new(false);

gix-index/src/verify.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub mod extensions {
4242
impl State {
4343
/// Assure our entries are consistent.
4444
pub fn verify_entries(&self) -> Result<(), entries::Error> {
45+
let _span = gix_features::trace::coarse!("gix_index::File::verify_entries()");
4546
let mut previous = None::<&crate::Entry>;
4647
for (idx, entry) in self.entries.iter().enumerate() {
4748
if let Some(prev) = previous {

0 commit comments

Comments
 (0)