mirror of
https://github.com/git/git.git
synced 2026-08-09 17:40:16 +00:00
commit-reach: remove commit-date ordering fallback
Remove the fallback that switched paint_down_to_common() from
generation ordering to commit-date ordering when the commit-graph
lacks corrected commit dates (v1 graph with topo levels only).
The fallback was added in 091f4cf3 (commit: don't use generation
numbers if not needed, 2018-08-30) to avoid a performance
regression on the Linux kernel repo where v1 topo levels caused
"git merge-base v4.8 v4.9" to walk 636k commits instead of 167k.
A side branch with a low topo level stayed in the queue behind a
long chain, preventing early STALE propagation.
Side-exhaustion (added in the previous commits) solves this
differently by terminating the walk as soon as one paint side
empties from the queue, preventing the deep walk regardless of
queue ordering. Benchmarks of "git merge-base --all v4.8 v4.9"
on the Linux kernel repo show that side-exhaustion reduces the
step count far below what the date-ordering fallback achieved:
steps time
no graph, baseline: 167,413 3.25 s
v1 graph, baseline: 167,413 0.25 s
v2 graph, baseline: 167,441 0.29 s
v1 graph, this series: 5,725 0.02 s
v2 graph, this series: 3,887 0.01 s
With generation ordering always active, the existing min_generation
check in paint_queue_get() correctly identifies when the walk has
reached the finite generation region. The date ordering fallback
broke this invariant: a commit could have a finite topo level
while the queue was date-ordered, causing the early exit to fire
before all merge bases were found.
For v1 commit-graphs where generation numbers saturate at
GENERATION_NUMBER_V1_MAX, introduce a topological ceiling that
the early exit gates compare against instead of
GENERATION_NUMBER_INFINITY. This ensures saturated commits are
treated as unordered, preventing premature termination when
generation values are unreliable.
Signed-off-by: Kristofer Karlsson <krka@spotify.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8d38fabe2c
commit
d43da5a2e8
@@ -89,9 +89,9 @@ struct paint_state {
|
||||
size_t parent1_count;
|
||||
size_t parent2_count;
|
||||
size_t mb_candidate_count;
|
||||
int gen_ordered;
|
||||
timestamp_t min_generation;
|
||||
timestamp_t last_gen;
|
||||
timestamp_t topo_ceiling;
|
||||
};
|
||||
|
||||
static void paint_count_update(struct paint_state *state,
|
||||
@@ -166,8 +166,7 @@ static struct commit *paint_queue_get(struct paint_state *state)
|
||||
|
||||
/* one side is exhausted */
|
||||
if ((!state->parent1_count || !state->parent2_count) &&
|
||||
state->gen_ordered &&
|
||||
generation < GENERATION_NUMBER_INFINITY)
|
||||
generation < state->topo_ceiling)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -187,9 +186,13 @@ static int paint_down_to_common(struct repository *r,
|
||||
enum merge_base_flags mb_flags,
|
||||
struct commit_list **result)
|
||||
{
|
||||
/*
|
||||
* Generation ordering is required for the side-exhaustion and
|
||||
* single-result early exits, which rely on topological traversal
|
||||
* order (children visited before parents) in the finite region.
|
||||
*/
|
||||
struct paint_state state = {
|
||||
.queue = { compare_commits_by_gen_then_commit_date },
|
||||
.gen_ordered = 1,
|
||||
.queue = { compare_commits_by_gen_then_commit_date }
|
||||
};
|
||||
struct commit *commit;
|
||||
int i;
|
||||
@@ -198,10 +201,9 @@ static int paint_down_to_common(struct repository *r,
|
||||
|
||||
state.min_generation = min_generation;
|
||||
state.last_gen = GENERATION_NUMBER_INFINITY;
|
||||
if (!min_generation && !corrected_commit_dates_enabled(r)) {
|
||||
state.queue.compare = compare_commits_by_commit_date;
|
||||
state.gen_ordered = 0;
|
||||
}
|
||||
state.topo_ceiling = corrected_commit_dates_enabled(r)
|
||||
? GENERATION_NUMBER_INFINITY
|
||||
: GENERATION_NUMBER_V1_MAX;
|
||||
|
||||
one->object.flags |= PARENT1;
|
||||
if (!n) {
|
||||
@@ -229,8 +231,7 @@ static int paint_down_to_common(struct repository *r,
|
||||
* descendant of this one.
|
||||
*/
|
||||
if (!(mb_flags & MERGE_BASE_FIND_ALL) &&
|
||||
state.gen_ordered &&
|
||||
state.last_gen < GENERATION_NUMBER_INFINITY)
|
||||
state.last_gen < state.topo_ceiling)
|
||||
break;
|
||||
}
|
||||
/* Mark parents of a found merge stale */
|
||||
|
||||
Reference in New Issue
Block a user