Merge commit

679a72c6b841baeb138f5c97e88e7e07d744e313

Merge branch 'kk/merge-base-exhaustion'

The merge-base computation has been optimized by stopping the walk
early when one side's exclusive commits in the queue are exhausted,
yielding significant speedups for queries with one-sided histories.

* kk/merge-base-exhaustion:
  commit-reach: remove commit-date ordering fallback
  commit-reach: move min_generation check into paint_queue_get()
  commit-reach: terminate merge-base walk when one paint side is exhausted
  commit-reach: introduce struct paint_state with per-side counters
  t6600: add clock-skew topologies and step counts for edge cases
  commit-reach: add trace2 instrumentation to paint_down_to_common()
  t6099: add side-exhaustion regression test
  t6600: add test cases for side-exhaustion edge cases
  test-lib-functions: improve diagnostic output for trace2 data assertions
  Documentation/technical: add paint-down-to-common doc

Junio C Hamano <gitster@pobox.com> · 2026-08-24 01:01 UTC

Browse files

Combined diff: only what this merge did beyond taking one side. Added lines are colored by the parent they came from; bold lines came from none of them; removed lines are red.

1 file changed, +16 −8
modified commit-reach.c
@@@ -104,19 -191,25 +191,26 @@@ static int paint_down_to_common(struct
191 enum merge_base_flags mb_flags,
192 struct commit_list **result)
193 {
- struct nonstale_queue queue = {
- { compare_commits_by_gen_then_commit_date }
194 + /*
195 + * Generation ordering is required for the side-exhaustion and
196 + * single-result early exits, which rely on topological traversal
197 + * order (children visited before parents) in the ordered region.
198 + */
199 + struct paint_state state = {
200 + .queue = { compare_commits_by_gen_then_commit_date }
201 };
202 + struct commit *commit;
203 int i;
- int gen_ordered = 1;
- timestamp_t last_gen = GENERATION_NUMBER_INFINITY;
204 + int steps = 0;
205 struct commit_list **tail = result;
206
- if (!min_generation && !corrected_commit_dates_enabled(r)) {
- queue.pq.compare = compare_commits_by_commit_date;
- gen_ordered = 0;
- }
207 + state.min_generation = min_generation;
208 + state.last_gen = GENERATION_NUMBER_INFINITY;
209 + state.topo_ceiling = corrected_commit_dates_enabled(r)
210 + ? GENERATION_NUMBER_INFINITY
211 + : GENERATION_NUMBER_V1_MAX;
212 +
213 +
214 one->object.flags |= PARENT1;
215 if (!n) {
216 commit_list_append(one, result);