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

Re: [PATCH 02/11] builtin/gc: move worktree and rerere tasks before object optimizations

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 7, 2026, 20:27 UTC
Message-ID
<xmqqbjci1r6z.fsf@gitster.g>
In-Reply-To
<20260707-b4-pks-odb-optimize-v1-2-aae607667be4@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 15 quoted lines
> In subsequent patches we'll consolidate all tasks that relate to
> maintenance of the object database and move it into the "files" backend.
> The relevant code is somewhat scattered though, as several other tasks
> are interspersed between.
>
> Refactor the code so that all object database optimizations are grouped
> together, which requires us to move worktree pruning and rerere garbage
> collection around. In theory, rearranging this code can have an effect
> on the object database optimizations:
>
>   - Rerere entries really shouldn't impact garbage collection at all, as
>     these entries are not stored in the object database.
>
>   - The index and HEAD reference of pruned worktrees may reference
>     objects that become unreachable.

Over time "gc" (and more prominently, "maintenance") ceased to be about object database optimization but about general housekeeping operations to keep your repository healthy. rerere database, reflog, packed-refs and reftable compaction are all outside the scope of object database optimization. Grouping these inside the umbrella "gc/maintenance" framework would be a good first step to make parts of them pluggable.

Show 44 quoted lines
> That being said, the impact should be overall rather negligible. If the
> user was asking us to prune objects with immediate expiration time then
> we might now prune objects that were previously still kept alive by the
> worktree. But besides being a very specific edge case, it's arguably not
> even the wrong thing to also prune any potentially-unreachable objects
> immediately.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  builtin/gc.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/builtin/gc.c b/builtin/gc.c
> index 77d0a5c948..8f568003ee 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -1011,6 +1011,13 @@ int cmd_gc(int argc,
>  	if (opts.detach <= 0 && !skip_foreground_tasks)
>  		gc_foreground_tasks(&opts, &cfg);
>  
> +	if (cfg.prune_worktrees_expire &&
> +	    maintenance_task_worktree_prune(&opts, &cfg))
> +		die(FAILED_RUN, "worktree");
> +
> +	if (maintenance_task_rerere_gc(&opts, &cfg))
> +		die(FAILED_RUN, "rerere");
> +
>  	if (!the_repository->repository_format_precious_objects) {
>  		struct child_process repack_cmd = CHILD_PROCESS_INIT;
>  
> @@ -1038,13 +1045,6 @@ int cmd_gc(int argc,
>  		}
>  	}
>  
> -	if (cfg.prune_worktrees_expire &&
> -	    maintenance_task_worktree_prune(&opts, &cfg))
> -		die(FAILED_RUN, "worktree");
> -
> -	if (maintenance_task_rerere_gc(&opts, &cfg))
> -		die(FAILED_RUN, "rerere");
> -
>  	report_garbage = report_pack_garbage;
>  	odb_reprepare(the_repository->objects);
>  	if (pack_garbage.nr > 0) {
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 6 of 33 in “odb: make optimizations pluggable”
  1. 00/11 odb: make optimizations pluggablePatrick Steinhardt, Jul 7, 2026
  2. 01/11 odb: run "pre-auto-gc" hook for all maintenance tasksPatrick Steinhardt, Jul 7, 2026
  3. Junio C HamanoJul 7, 2026
  4. Patrick SteinhardtJul 8, 2026
  5. 02/11 builtin/gc: move worktree and rerere tasks before object optimizationsPatrick Steinhardt, Jul 7, 2026
  6. Junio C HamanoJul 7, 2026
  7. 03/11 builtin/gc: extract object database optimizations into separate functionPatrick Steinhardt, Jul 7, 2026
  8. Junio C HamanoJul 7, 2026
  9. 04/11 builtin/gc: make repack arguments self-containedPatrick Steinhardt, Jul 7, 2026
  10. 05/11 builtin/gc: inline config values specific to the "files" backendPatrick Steinhardt, Jul 7, 2026
  11. 06/11 builtin/gc: introduce object database optimization optionsPatrick Steinhardt, Jul 7, 2026
  12. 07/11 builtin/gc: move geometric repacking into `odb_optimize()`Patrick Steinhardt, Jul 7, 2026
  13. 08/11 builtin/gc: introduce `odb_optimize_required()`Patrick Steinhardt, Jul 7, 2026
  14. 09/11 builtin/gc: refactor ODB optimizations to operate on "files" sourcePatrick Steinhardt, Jul 7, 2026
  15. 10/11 builtin/gc: fix signedness issues in ODB-related functionalityPatrick Steinhardt, Jul 7, 2026
  16. 11/11 odb: make optimizations pluggablePatrick Steinhardt, Jul 7, 2026
  17. 00/12 odb: make optimizations pluggablePatrick Steinhardt, Jul 13, 2026
  18. 01/12 t7900: simplify how we check for maintenance tasksPatrick Steinhardt, Jul 13, 2026
  19. 02/12 odb: run "pre-auto-gc" hook for all maintenance tasksPatrick Steinhardt, Jul 13, 2026
  20. 03/12 builtin/gc: move worktree and rerere tasks before object optimizationsPatrick Steinhardt, Jul 13, 2026
  21. 04/12 builtin/gc: extract object database optimizations into separate functionPatrick Steinhardt, Jul 13, 2026
  22. 05/12 builtin/gc: make repack arguments self-containedPatrick Steinhardt, Jul 13, 2026
  23. 06/12 builtin/gc: inline config values specific to the "files" backendPatrick Steinhardt, Jul 13, 2026
  24. 07/12 builtin/gc: introduce object database optimization optionsPatrick Steinhardt, Jul 13, 2026
  25. 08/12 builtin/gc: move geometric repacking into `odb_optimize()`Patrick Steinhardt, Jul 13, 2026
  26. 09/12 builtin/gc: introduce `odb_optimize_required()`Patrick Steinhardt, Jul 13, 2026
  27. 10/12 builtin/gc: refactor ODB optimizations to operate on "files" sourcePatrick Steinhardt, Jul 13, 2026
  28. 11/12 builtin/gc: fix signedness issues in ODB-related functionalityPatrick Steinhardt, Jul 13, 2026
  29. Junio C HamanoJul 13, 2026
  30. Patrick SteinhardtJul 22, 2026
  31. Junio C HamanoJul 26, 2026
  32. 12/12 odb: make optimizations pluggablePatrick Steinhardt, Jul 13, 2026
  33. Junio C HamanoJul 13, 2026

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.