Re: [PATCH 0/4] pack-objects: create new name-hash algorithm
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Sep 10, 2024, 02:37 UTC
- Message-ID
- <0e6dde0f-63e2-4db3-9225-9a8ca5e78eb3@gmail.com>
- In-Reply-To
- <xmqqjzfkr9b0.fsf@gitster.g>
On 9/9/24 2:06 PM, Junio C Hamano wrote:
Show 23 quoted lines
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes: > >> One way to find some improvement in these repositories is to increase the >> window size, which was an initial indicator that the delta compression could >> be improved, but was not a clear indicator. After some digging (and >> prototyping some analysis tools) the main discovery was that the current >> name-hash algorithm only considers the last 16 characters in the path name >> and has some naturally-occurring collisions within that scope. > > Yes, as I explained in the other message, this "collision" is an > integral part of the design to allow us gather candidates together > that may yield good deltas among them. In addition, header files > whose names end with ".h" tend to share a bit comment at the > beginning of them in many projects, and the proximity (not > "collision") of the hash value is used to make them delta candidates > with each other. > > I do agree that considering files at the same path from different > (but close-by) revisions as the prime candidates is very important, > but if you spread the "collissions" very thin by using "uniform > distribution", I am afraid that you'd end up discarding anything but > the blobs at the same path, which may go too far. Having name hash > value that are close by no longer has any meaning in such a system.
You are right that some "nearby" paths are lost in this change, and this can be measured by trying to use this option in the pack-objects process underneath a small 'git push'.
The thing that surprised me is just how effective this is for the creation of large pack-files that include many versions of most files. The cross-path deltas have less of an effect here, and the benefits of avoiding name-hash collisions can be overwhelming in many cases.
Show 9 quoted lines
> I hope you can find a solution that strikes a good balance at the > end of the series (I saw only the first step), but I suspect an easy > way to avoid the downsides you observed is to use both. Compare > with a handful of blobs taken from nearby commits (the original > object order is roughly in traversal order, and you can take > advantage of that fact) from exactly the same path (using your > "uniform distribution") before comparing with the blobs with close > value (of the current function) like the current implementation > does, may go a long way.
Funny you should say that, since the RFC I finally submitted [1] actually does just that. The --path-walk option changes the object walk to consider batches of objects based on their path, computes deltas among that batch, and then does the normal name-hash pass later. This seems to really strike the balance that you are looking for and solves the issues where small pushes need to stay small. It also fixes some problematic cases even when pushing a single commit.
[1] https://lore.kernel.org/git/pull.1786.git.1725935335.gitgitgadget@gmail.com/
However, the --path-walk option requires significant implementation of a "path walk API" and my RFC doesn't even do threading right. The --path-walk version (probably) doesn't work with delta islands or other features the same way as the drop-in change to the name- hash heuristic can. For that reason, I think there is likely some long-term value to the --full-name-hash option even though the --path-walk option will be better in many cases.
Thanks, -Stolee