Skip to content

delta-islands: revisit trees with new delta marks - #2343

Open
derrickstolee wants to merge 1 commit into
gitgitgadget:masterfrom
derrickstolee:delta-islands
Open

derrickstolee wants to merge 1 commit into
gitgitgadget:masterfrom
derrickstolee:delta-islands

Conversation

@derrickstolee

@derrickstolee derrickstolee commented Nov 30, 2026 •

Copy link
Copy Markdown

Discovered while working on a real application of delta islands and the --path-walk feature.

cc: gitster@pobox.com
cc: peff@peff.net
cc: ttaylorr@openai.com
cc: newren@gmail.com

@derrickstolee

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 30, 2026

Copy link
Copy Markdown

Submitted as pull.2343.git.1796066735611.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2343/derrickstolee/delta-islands-v1

To fetch this version to local tag pr-2343/derrickstolee/delta-islands-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2343/derrickstolee/delta-islands-v1

When exploring the object graph to group objects into delta-islands,
some trees and blobs can be visited from one path and then revisited
later from another. If those two visits come from objects with different
delta marks, then the final mark of the visited object should be the
union of those marks. Instead, some cases only have the first marks as
we don't reprocess objects marked with SEEN. This gets worse for objects
recursively reachable from that object.

This change includes some test cases that demonstrate this problem, and
several of the modes fail without the accompanying code change. These
examples were discovered while working with the --path-walk option as
integrated with delta islands in 7e6de2a (pack-objects: support
`--delta-islands` with `--path-walk`, 2026-06-21), but that option only
exposed an existing failure within the marking algorithm. At least
one of the new tests exposes a failure without --path-walk.

The issue is not just about different path names, but about appearing at
paths of different depth. For example, a tree appearing at a/b/ can be
visited with one set of marks as supplied from the trees at a/ while
later being seen at x/y/z/ with different marks supplied by objects at
x/y/.

To fix this issue, we need to potentially reprocess a tree and
everything it can reach when we discover an update to the delta island
marks. This can lead to massive recomputation with certain data shapes
that revisit objects from different paths. This seems unlikely to happen
often in realistic scenarios, but is unavoidable without topologically
sorting the entire object graph before distributing marks.

Concretely, update set_island_marks() to report whether the object
gained any bits in the process. Use a depth-priority queue to revisit
trees that have new marks. We need to be careful to avoid adding
duplicates to the queue without replicating the SEEN bit. This depth
heuristic is only to prioritize a breadth-first-search, handling root
trees before the next set of trees, and so on. This is intended to
maximize the possibility of seeing all links to an object before
visiting that object.

The first-seen-depth problem was identified during the original
delta-island review [1]: SEEN prevents revisiting shared trees, so their
recorded depths need not give a topological ordering. That discussion
illustrated missed delta opportunities. Incomplete marks can also allow
unwanted cross-island deltas, as acknowledged for a related root-depth
bug in 3949053 (pack-objects: fix off-by-one in delta-island
tree-depth computation, 2018-11-20) [2]. Later discussion emphasized
real fork-network results and the difficulty of constructing focused
corner-case tests [3].

[1] https://lore.kernel.org/git/20180727130229.GB18599@sigill.intra.peff.net/
[2] https://lore.kernel.org/git/20181120095053.GC22742@sigill.intra.peff.net/
[3] https://lore.kernel.org/git/20181120113423.GA29319@sigill.intra.peff.net/

Using p5305's historical-fork island selection, with --no-path-walk,
bitmap reads disabled, --window=0, --compression=0, and stored deltas
reusable, gives these old-to-fixed command times and tree visits:

                           Time (s)           Tree visits
    git/git              8.08 ->   8.24      162,791 ->   162,795
    nodejs/node          9.85 ->  10.14      238,723 ->   239,837
    microsoft/fluentui   4.13 ->   4.24      287,056 ->   287,136
    torvalds/linux     176.28 -> 170.73    6,888,020 -> 6,888,085

It's possible that a true integration of delta islands with path-walk
would help here, having the path-walk API compute the delta island marks
as we traverse objects in path-based groups. Such an implementation
would need to allow for objects to be readded to groups when their delta
marks are updated while avoiding multiple emissions of the object from
the API. Such a large rework of the delta island computation is avoided
for now, as we can reproduce the error with the existing implementation.

Assisted-by: GPT-6.1 Sol
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant