Subject: Re: Auto packing the repository - foreground or background in Windows?

From: Derrick Stolee <[email-masked]>
Date: Tue, 6 Dec 2022 13:03:35 -0500

On 12/1/2022 7:25 AM, Tao Klerks wrote: 
> But my *question* is: Does anyone know where I could/should look to
> understand why the GC was happening in the foreground, even though the
> message says it will run in the background?

On Windows, Git's foreground process cannot complete without also
killing the background process. I'm not sure on the concrete details,
but the lack of a background "git gc --auto" here is deliberate for
that platform.
 
> I don't know how to create the conditions for the auto-GC on demand
> (how to create lots of loose objects??), so I don't know how to verify
> whether it ever runs in the background on Windows, or what that might
> depend on. I saw some discussions in 2016, but I can't tell what the
> conclusion was; is it simply the case that git has been "lying" about
> running GC in the background, on windows, for all these years? Or is
> there something specific going on in this user's environment?

Instead, the modern recommendation for repositories where "git gc --auto"
would be slow is to run "git maintenance start" which will schedule
background maintenance jobs with the Windows scheduler. Those processes
are built to do updates that are non-invasive to concurrent foreground
processes. It also sets config to avoid "git gc --auto" commands at the
end of foreground Git processes.

See [1] for more details.

[1] https://git-scm.com/docs/git-maintenance

Thanks,
-Stolee