Subject: Re: [PATCH v3] repack: enable bitmaps by default on bare repos

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Fri, 24 May 2019 09:55:05 +0200

On Fri, May 24 2019, Jeff King wrote:

> On Thu, May 23, 2019 at 09:26:34PM +0200, Ævar Arnfjörð Bjarmason wrote:
>
>> > I spent a while thinking and experimenting with this tonight. The result
>> > is the patch below. Ævar, do you still have a copy of the repo that
>> > misbehaved? I'd be curious to see how it fares.
>>
>> No, sorry. I think we could make an artificial test to emulate it, which
>> would be something like:
>>
>>  * ~1 million commits
>>  * local clone setup to fetch all branches/tags (default 'git clone')
>>  * local a bit ahead/behind
>>  * Have old "main" pack with *.bitmap, bunch of other packs/loose objects without that
>>  * push try to push the local change upstream (or to a topic branch)
>>
>> I tried briefly to emulate this with git.git with:
>> [...]
>> But didn't get anywhere, probably because here my topics are all stuff I
>> have already, and I just have 2x packs.
>
> Yeah, I haven't been able to find a reproduction for this problem at
> will. The bitmaps are _supposed_ to be sprinkled around through the
> commit graph so that we don't have to walk far. But presumably in your
> case that was not so.
>
> I'm not sure what tickles the bitmap-writer to fail so hard. Is it
> having too many refs? Weird patterns in the graph? Just a ton of
> commits?

Ah, why did only this ancient (big) pack have a bitmap?

The bitmap writer had never failed, this was just a repository where
some automation (on a dev/staging box) cloned a repo, and someone had
once run a manual "repack" to make make a pack with a bitmap.

Then as time passed that pack stayed around, and re-looking at this that
could have only happened because I had gc.bigPackThreshold turned on.

I.e. without that we'd have eventually done a full repack, so the bitmap
would have gone away.

So getting the repo into that state was a series of unlikely events.

I think to the extent that this is an issue we can reproduce in the
future the proper fix for it in lieu of some easy fix in the bitmap code
would be to just teach "gc" to unlink old *.bitmap files if we detect
they're too stale.

I.e. we don't need to deal gracefully with some case where the bitmaps
just cover some tiny part of the graph, we can just teach "gc" to either
update them, or (if we're not currently writing them) unlink them.

That seems to me to be a good idea in general, not just with bitmaps but
also the commit graph. If we're doing a GC and our current settings
aren't such that we'd update those files, shouldn't we just unlink them?