Skip to content

Commit 6f5e386

Browse files
committed
improve performance of commit-graph variant ever-so-slightly
In practice, what really matters is to reuse as much of the previous computation as possible. Re-using the graph (or its menory) doesn't do much, but reusing the parsed commits would be a huge benefit when running many queries after another.
1 parent 6d8612c commit 6f5e386

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

gix-revision/src/merge_base.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ pub(crate) mod function {
4444
others: &[ObjectId],
4545
graph: &mut Graph<'_, '_, Flags>,
4646
) -> Result<Option<Vec<ObjectId>>, Error> {
47-
let _span = gix_trace::coarse!("gix_revision::merge_base()", ?first, ?others,);
47+
let _span = gix_trace::coarse!("gix_revision::merge_base()",?first,?others);
4848
if others.is_empty() || others.contains(&first) {
4949
return Ok(Some(vec![first]));
5050
}
5151

52+
graph.clear();
5253
let bases = paint_down_to_common(first, others, graph)?;
5354
graph.clear();
5455

@@ -62,6 +63,7 @@ pub(crate) mod function {
6263
commits: &[(ObjectId, GenThenTime)],
6364
graph: &mut Graph<'_, '_, Flags>,
6465
) -> Result<Vec<ObjectId>, Error> {
66+
let _span = gix_trace::detail!("gix_revision::remove_redundant()", num_commits = %commits.len());
6567
if commits.is_empty() {
6668
return Ok(Vec::new());
6769
}
@@ -217,11 +219,10 @@ pub(crate) mod function {
217219
type Error = gix_object::decode::Error;
218220

219221
fn try_from(commit: LazyCommit<'_, '_>) -> Result<Self, Self::Error> {
222+
let (generation, timestamp) = commit.generation_and_timestamp()?;
220223
Ok(GenThenTime {
221-
generation: commit
222-
.generation()
223-
.unwrap_or(gix_commitgraph::GENERATION_NUMBER_INFINITY),
224-
time: commit.committer_timestamp()?,
224+
generation: generation.unwrap_or(gix_commitgraph::GENERATION_NUMBER_INFINITY),
225+
time: timestamp,
225226
})
226227
}
227228
}

0 commit comments

Comments
 (0)