Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 02/11] builtin/gc: move worktree and rerere tasks before object optimizations
Date: Tue, 07 Jul 2026 13:27:00 -0700	[thread overview]
Message-ID: <xmqqbjci1r6z.fsf@gitster.g> (raw)
In-Reply-To: <20260707-b4-pks-odb-optimize-v1-2-aae607667be4@pks.im> (Patrick Steinhardt's message of "Tue, 07 Jul 2026 17:32:34 +0200")

Patrick Steinhardt <ps@pks.im> writes:

> 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.

> 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) {

  reply	other threads:[~2026-07-07 20:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 15:32 [PATCH 00/11] odb: make optimizations pluggable Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 01/11] odb: run "pre-auto-gc" hook for all maintenance tasks Patrick Steinhardt
2026-07-07 19:55   ` Junio C Hamano
2026-07-08  7:55     ` Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 02/11] builtin/gc: move worktree and rerere tasks before object optimizations Patrick Steinhardt
2026-07-07 20:27   ` Junio C Hamano [this message]
2026-07-07 15:32 ` [PATCH 03/11] builtin/gc: extract object database optimizations into separate function Patrick Steinhardt
2026-07-07 20:30   ` Junio C Hamano
2026-07-07 15:32 ` [PATCH 04/11] builtin/gc: make repack arguments self-contained Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 05/11] builtin/gc: inline config values specific to the "files" backend Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 06/11] builtin/gc: introduce object database optimization options Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 07/11] builtin/gc: move geometric repacking into `odb_optimize()` Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 08/11] builtin/gc: introduce `odb_optimize_required()` Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 09/11] builtin/gc: refactor ODB optimizations to operate on "files" source Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 10/11] builtin/gc: fix signedness issues in ODB-related functionality Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 11/11] odb: make optimizations pluggable Patrick Steinhardt
2026-07-13  5:52 ` [PATCH v2 00/12] " Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 01/12] t7900: simplify how we check for maintenance tasks Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 02/12] odb: run "pre-auto-gc" hook for all " Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 03/12] builtin/gc: move worktree and rerere tasks before object optimizations Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 04/12] builtin/gc: extract object database optimizations into separate function Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 05/12] builtin/gc: make repack arguments self-contained Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 06/12] builtin/gc: inline config values specific to the "files" backend Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 07/12] builtin/gc: introduce object database optimization options Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 08/12] builtin/gc: move geometric repacking into `odb_optimize()` Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 09/12] builtin/gc: introduce `odb_optimize_required()` Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 10/12] builtin/gc: refactor ODB optimizations to operate on "files" source Patrick Steinhardt
2026-07-13  5:52   ` [PATCH v2 11/12] builtin/gc: fix signedness issues in ODB-related functionality Patrick Steinhardt
2026-07-13 16:28     ` Junio C Hamano
2026-07-13  5:52   ` [PATCH v2 12/12] odb: make optimizations pluggable Patrick Steinhardt
2026-07-13 16:34     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqbjci1r6z.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox