pr-2170/spkrka/krka/fix-topo-levels-slab-v2
tagged this
09 Jul 15:03
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-09-04), 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. Commits
from lower layers appear to have no generation numbers, so the DFS re-walks
the entire ancestry.
On a repo with a multi-layer split commit-graph, an incremental commit-graph
write triggered by git fetch drops from ~3.5 seconds to ~0.2 seconds after
the fix.
[1]
https://lore.kernel.org/git/aMNTELw0Wk8jWoPc@nand.local/T/#mb55b5f0e1ccf82d969ac1d8144c56ecf87b833e8
Changes since v1:
* Fixed wrong commit title and date in the reference (Junio, Taylor).
* use test_expect_failure with the correct assertion instead of a # BUG
comment (Taylor).
* Simplified commit messages.
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: f85a7e662054a7b0d9070e432508831afa214b47
Submitted-As: https://lore.kernel.org/git/pull.2170.v2.git.1783609382.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2170.git.1783418384.gitgitgadget@gmail.com