git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Dec 6, 2022, 19:19 UTC
Message-ID
<221206.86o7sgbagq.gmgdl@evledraar.gmail.com>
In-Reply-To
<4dcad1f5-9ebd-d15a-b663-a3513ae1bcb8@github.com>
On Tue, Dec 06 2022, Derrick Stolee wrote:
Show 28 quoted lines
> 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

That's good advice, but Tao is pointing out that the message we emit is buggy here, which is a correct.

The problem is just that on Windows we always fail to daemonize(), but didn't correct the bits that know that to the bits that emit the message.

I think this should fix it:
	
	diff --git a/builtin/gc.c b/builtin/gc.c
	index 02455fdcd73..a5f599ebff0 100644
	--- a/builtin/gc.c
	+++ b/builtin/gc.c
	@@ -623,9 +623,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
	 		if (!need_to_gc())
	 			return 0;
	 		if (!quiet) {
	+#ifndef NO_POSIX_GOODIES
	 			if (detach_auto)
	 				fprintf(stderr, _("Auto packing the repository in background for optimum performance.\n"));
	 			else
	+#endif
	 				fprintf(stderr, _("Auto packing the repository for optimum performance.\n"));
	 			fprintf(stderr, _("See \"git help gc\" for manual housekeeping.\n"));
	 		}
Tao: If you're interested do you mind carrying that (or some other
similar) patch forward?
The above is: Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Previous: Derrick StoleeNext: Jeff Hostetler
Message 3 of 7 in “Auto packing the repository - foreground or background in Windows?”
  1. Tao KlerksDec 1, 2022
  2. Derrick StoleeDec 6, 2022
  3. Ævar Arnfjörð BjarmasonDec 6, 2022
  4. Jeff HostetlerDec 6, 2022
  5. Tao KlerksDec 8, 2022
  6. Tao KlerksDec 8, 2022
  7. Derrick StoleeDec 9, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.