Repository navigation
pr-2343/derrickstolee/delta-islands-v1
tagged this
30 Nov 19:25
From: Derrick Stolee <stolee@gmail.com>
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 7e6de2ac628 (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 3949053617 (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 <dstolee@microsoft.com>
Submitted-As: https://lore.kernel.org/git/pull.2343.git.1796066735611.gitgitgadget@gmail.com