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

Re: [RFC/PATCH] gc: run more pre-detach operations under lock

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 19, 2019, 22:49 UTC
Message-ID
<87imt18a2r.fsf@evledraar.gmail.com>
In-Reply-To
<20190619191037.GE28145@sigill.intra.peff.net>
On Wed, Jun 19 2019, Jeff King wrote:
Show 31 quoted lines
> On Wed, Jun 19, 2019 at 08:01:55PM +0200, Ævar Arnfjörð Bjarmason wrote:
>
>> > You could sort of avoid the problem here too with
>> >
>> > parallel 'git fetch --no-auto-gc {}' ::: $(git remote)
>> > git gc --auto
>> >
>> > It's definitely simpler, but of course we have to manually add
>> > --no-auto-gc in everywhere we need, so not quite as elegant.
>> >
>> > Actually you could already do that with 'git -c gc.auto=false fetch', I guess.
>>
>> The point of the 'parallel' example is to show disconnected git
>> commands, think trying to run 'git' in a terminal while your editor
>> asynchronously runs a polling 'fetch', or a server with multiple
>> concurrent clients running 'gc --auto'.
>>
>> That's the question my RFC patch raises. As far as I can tell the
>> approach in your patch is only needed because our locking for gc is
>> buggy, rather than introduce the caveat that an fetch(N) operation won't
>> do "gc" until it's finished (we may have hundreds, thousands of remotes,
>> I use that for some more obscure use-cases) shouldn't we just fix the
>> locking?
>
> I think there may be room for both approaches. Yours fixes the repeated
> message in the more general case, but Duy's suggestion is the most
> efficient thing.
>
> I agree that the "thousands of remotes" case means we might want to gc
> in the interim. But we probably ought to do that deterministically
> rather than hoping that the pattern of lock contention makes sense.

We do it deterministically, when gc.auto thresholds et al are exceeded we kick one off without waiting for other stuff, if we can get the lock.

I don't think this desire to just wait a bit until all the fetches are complete makes sense as a special-case.

If, as you noted in <20190619190845.GD28145@sigill.intra.peff.net>, the desire is to reduce GC CPU use then you're better off just tweaking the limits upwards. Then you get that with everything, like when you run "commit" in a for-loop, not just this one special case of "fetch".

We have existing potentially long-running operations like "fetch", "rebase" and "git svn fetch" that run "gc --auto" for their incremental steps, and that's a feature.

It keeps "gc --auto" dumb enough to avoid a pathological case where we'll have a ballooning objects dir because we figure we can run something "at the end", when "the end" could be hours away, and we're adding a new pack or hundreds of loose objects every second.

So I don't think Duy's patch is a good way to go.

The rationale in its commit message for including it can be better addressed by something like my WIP for just fixing the locking mechanism, since it fixes the stated problems of multiple "auto packing in the background" messages and the "we may waste some resources" (we take the lock earlier before doing 'real' work) without introducing its own pathological case of deferring "gc --auto" too much as we have unchecked object growth.

I think that's really important. It's OK if "gc --auto" isn't optimal, but we should really avoid such pathological cases.

It's also important that it's easy to explain, i.e. if this patch goes in I think it should update the second paragraph of the git-gc.txt docs. I.e. now it's not just:

    When common porcelain operations that create objects are run, they
    will check whether the repository has grown substantially since the
    last maintenance[...]
But also something like:
    Except in cases where we're running porcelain commads that
    themselves might re-run aggregates of themselves, in which case we
    defer "gc" until the end. This currently only applies to "fetch",
    but other commands such as "rebase" etc. might learn to do this in
    the future. Note that if the sub-commands are numerous enough this
    might itself become pathological as "gc --auto" is deferred too
    much, so use option/config XYZ to ...
Or whatever...
Previous: Jeff KingNext: Ævar Arnfjörð Bjarmason
Message 6 of 61 in “fetch: only run 'gc' once when fetching multiple remotes”
  1. fetch: only run 'gc' once when fetching multiple remotesNguyễn Thái Ngọc Duy, Jun 19, 2019
  2. gc: run more pre-detach operations under lockÆvar Arnfjörð Bjarmason, Jun 19, 2019
  3. Duy NguyenJun 19, 2019
  4. Ævar Arnfjörð BjarmasonJun 19, 2019
  5. Jeff KingJun 19, 2019
  6. Ævar Arnfjörð BjarmasonJun 19, 2019
  7. 0/6 Change <non-empty?> GIT_TEST_* variables to <boolean>Ævar Arnfjörð Bjarmason, Jun 19, 2019
  8. Junio C HamanoJun 20, 2019
  9. Ævar Arnfjörð BjarmasonJun 20, 2019
  10. Junio C HamanoJun 20, 2019
  11. 0/8 Change <non-empty?> GIT_TEST_* variables to <boolean>Ævar Arnfjörð Bjarmason, Jun 20, 2019
  12. 1/8 config tests: simplify include cycle testÆvar Arnfjörð Bjarmason, Jun 21, 2019
  13. 0/8 Change <non-empty?> GIT_TEST_* variables to <boolean>Ævar Arnfjörð Bjarmason, Jun 21, 2019
  14. 2/8 env--helper: new undocumented builtin wrapping git_env_*()Ævar Arnfjörð Bjarmason, Jun 21, 2019
  15. Junio C HamanoJun 21, 2019
  16. 3/8 config.c: refactor die_bad_number() to not call gettext() earlyÆvar Arnfjörð Bjarmason, Jun 21, 2019
  17. 4/8 t6040 test: stop using global "script" variableÆvar Arnfjörð Bjarmason, Jun 21, 2019
  18. 6/8 tests README: re-flow a previously changed paragraphÆvar Arnfjörð Bjarmason, Jun 21, 2019
  19. 5/8 tests: make GIT_TEST_GETTEXT_POISON a booleanÆvar Arnfjörð Bjarmason, Jun 21, 2019
  20. Junio C HamanoJun 24, 2019
  21. 7/8 tests: replace test_tristate with "git env--helper"Ævar Arnfjörð Bjarmason, Jun 21, 2019
  22. 1/2 t/lib-git-svn.sh: check GIT_TEST_SVN_HTTPD when running SVN HTTP testsSZEDER Gábor, Sep 6, 2019
  23. 2/2 ci: restore running httpd testsSZEDER Gábor, Sep 6, 2019
  24. Junio C HamanoSep 6, 2019
  25. Jeff KingSep 6, 2019
  26. SZEDER GáborSep 7, 2019
  27. 0/2 tests: catch non-bool GIT_TEST_* valuesSZEDER Gábor, Nov 22, 2019
  28. 1/2 tests: add 'test_bool_env' to catch non-bool GIT_TEST_* valuesSZEDER Gábor, Nov 22, 2019
  29. Jeff KingNov 25, 2019
  30. 2/2 t5608-clone-2gb.sh: turn GIT_TEST_CLONE_2GB into a boolSZEDER Gábor, Nov 22, 2019
  31. Jeff KingNov 25, 2019
  32. 8/8 tests: make GIT_TEST_FAIL_PREREQS a booleanÆvar Arnfjörð Bjarmason, Jun 21, 2019
  33. 1/8 config tests: simplify include cycle testÆvar Arnfjörð Bjarmason, Jun 20, 2019
  34. 2/8 env--helper: new undocumented builtin wrapping git_env_*()Ævar Arnfjörð Bjarmason, Jun 20, 2019
  35. Junio C HamanoJun 20, 2019
  36. Junio C HamanoJun 20, 2019
  37. Ævar Arnfjörð BjarmasonJun 21, 2019
  38. Junio C HamanoJun 21, 2019
  39. 3/8 config.c: refactor die_bad_number() to not call gettext() earlyÆvar Arnfjörð Bjarmason, Jun 20, 2019
  40. 4/8 t6040 test: stop using global "script" variableÆvar Arnfjörð Bjarmason, Jun 20, 2019
  41. 5/8 tests: make GIT_TEST_GETTEXT_POISON a booleanÆvar Arnfjörð Bjarmason, Jun 20, 2019
  42. 7/8 tests: replace test_tristate with "git env--helper"Ævar Arnfjörð Bjarmason, Jun 20, 2019
  43. 6/8 tests README: re-flow a previously changed paragraphÆvar Arnfjörð Bjarmason, Jun 20, 2019
  44. 8/8 tests: make GIT_TEST_FAIL_PREREQS a booleanÆvar Arnfjörð Bjarmason, Jun 20, 2019
  45. 1/6 env--helper: new undocumented builtin wrapping git_env_*()Ævar Arnfjörð Bjarmason, Jun 19, 2019
  46. Junio C HamanoJun 20, 2019
  47. 2/6 t6040 test: stop using global "script" variableÆvar Arnfjörð Bjarmason, Jun 19, 2019
  48. Junio C HamanoJun 20, 2019
  49. 3/6 tests: make GIT_TEST_GETTEXT_POISON a booleanÆvar Arnfjörð Bjarmason, Jun 19, 2019
  50. Junio C HamanoJun 20, 2019
  51. 5/6 tests: replace test_tristate with "git env--helper"Ævar Arnfjörð Bjarmason, Jun 19, 2019
  52. 4/6 tests README: re-flow a previously changed paragraphÆvar Arnfjörð Bjarmason, Jun 19, 2019
  53. 6/6 tests: make GIT_TEST_FAIL_PREREQS a booleanÆvar Arnfjörð Bjarmason, Jun 19, 2019
  54. Duy NguyenJun 20, 2019
  55. Ævar Arnfjörð BjarmasonJun 20, 2019
  56. Jeff KingJun 20, 2019
  57. Junio C HamanoJun 20, 2019
  58. Jeff KingJun 19, 2019
  59. Jeff KingJun 19, 2019
  60. Duy NguyenJun 20, 2019
  61. Jeff KingJun 20, 2019

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.