Git development
 help / color / mirror / Atom feed
* [PATCH 0/2] commit-graph: fix topo_levels slab propagation regression
@ 2026-07-07  9:59 Kristofer Karlsson via GitGitGadget
  2026-07-07  9:59 ` [PATCH 1/2] commit-graph: add trace2 instrumentation for generation DFS Kristofer Karlsson via GitGitGadget
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Kristofer Karlsson via GitGitGadget @ 2026-07-07  9:59 UTC (permalink / raw)
  To: git; +Cc: Kristofer Karlsson

When fetch.writeCommitGraph is enabled (or git maintenance runs after
fetch), an incremental commit-graph write computes generation numbers for
the newly added commits. For commits already in the graph, their topo levels
should be read from the existing layers, making the DFS proportional to the
number of new commits.

199d452758 (commit-graph: return the prepared commit graph from
prepare_commit_graph(), 2025-04-07), part of the ps/commit-graph-via-source
series [1], refactored the loop that propagates the topo_levels slab to each
layer of the commit-graph chain. The original code used a single variable
that advanced through the chain:

while (g) {
    g->topo_levels = &topo_levels;
    g = g->base_graph;
}


The refactored code introduced a separate iteration variable but did not
update the loop body to match:

for (struct commit_graph *chain = g; chain; chain = chain->base_graph)
    g->topo_levels = &topo_levels;


This always assigns to the topmost layer instead of the current one. The
other loops in the same refactoring all correctly use chain in their bodies:

for (struct commit_graph *chain = g; chain; chain = chain->base_graph)
    ctx.num_commit_graphs_before++;

for (struct commit_graph *chain = g; chain; chain = chain->base_graph)
    ctx.commit_graph_filenames_before[--i] = xstrdup(chain->filename);


With only the topmost layer having topo_levels set, fill_commit_graph_info()
cannot store topo levels for commits parsed from lower layers.
compute_reachable_generation_numbers() then sees GENERATION_NUMBER_ZERO for
those commits and re-walks their entire ancestry.

On a large repo with a 4-layer split commit-graph, the cost of a single
incremental commit-graph write drops from 4133ms to 233ms after the fix,
which directly impacts every git fetch when commit-graph maintenance is
enabled.

[1]
https://lore.kernel.org/git/aMNTELw0Wk8jWoPc@nand.local/T/#mb55b5f0e1ccf82d969ac1d8144c56ecf87b833e8

Kristofer Karlsson (2):
  commit-graph: add trace2 instrumentation for generation DFS
  commit-graph: propagate topo_levels slab to all chain layers

 commit-graph.c                |  7 ++++++-
 t/t5324-split-commit-graph.sh | 24 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)


base-commit: e9019fcafe0040228b8631c30f97ae1adb61bcdc
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2170%2Fspkrka%2Fkrka%2Ffix-topo-levels-slab-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2170/spkrka/krka/fix-topo-levels-slab-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2170
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2026-07-14  3:31 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07  9:59 [PATCH 0/2] commit-graph: fix topo_levels slab propagation regression Kristofer Karlsson via GitGitGadget
2026-07-07  9:59 ` [PATCH 1/2] commit-graph: add trace2 instrumentation for generation DFS Kristofer Karlsson via GitGitGadget
2026-07-07 13:46   ` Taylor Blau
2026-07-07 14:08     ` Kristofer Karlsson
2026-07-10 22:09       ` Taylor Blau
2026-07-10 22:28         ` Junio C Hamano
2026-07-10 22:56           ` Taylor Blau
2026-07-11 21:18             ` Junio C Hamano
2026-07-13 19:55               ` Kristofer Karlsson
2026-07-13 20:42                 ` Junio C Hamano
2026-07-13 22:17                   ` Kristofer Karlsson
2026-07-07 16:55   ` Junio C Hamano
2026-07-07 17:39     ` Kristofer Karlsson
2026-07-07  9:59 ` [PATCH 2/2] commit-graph: propagate topo_levels slab to all chain layers Kristofer Karlsson via GitGitGadget
2026-07-07 13:49   ` Taylor Blau
2026-07-07 14:02     ` Kristofer Karlsson
2026-07-07 14:57     ` Kristofer Karlsson
2026-07-10 22:14       ` Taylor Blau
2026-07-13  6:16         ` Patrick Steinhardt
2026-07-14  3:31           ` Taylor Blau
2026-07-07 17:00   ` Junio C Hamano
2026-07-07 17:42     ` Kristofer Karlsson
2026-07-07 20:13       ` Junio C Hamano
2026-07-09 13:43   ` Patrick Steinhardt
2026-07-09 15:02 ` [PATCH v2 0/2] commit-graph: fix topo_levels slab propagation regression Kristofer Karlsson via GitGitGadget
2026-07-09 15:03   ` [PATCH v2 1/2] commit-graph: add trace2 instrumentation for generation DFS Kristofer Karlsson via GitGitGadget
2026-07-09 15:03   ` [PATCH v2 2/2] commit-graph: propagate topo_levels slab to all chain layers Kristofer Karlsson via GitGitGadget
2026-07-10 22:15   ` [PATCH v2 0/2] commit-graph: fix topo_levels slab propagation regression Taylor Blau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox