From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Phillip Wood <phillip.wood123@gmail.com>,
phillip.wood@dunelm.org.uk, James Liu <james@jamesliu.io>,
Derrick Stolee <stolee@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v3 0/7] builtin/maintenance: fix auto-detach with non-standard tasks
Date: Fri, 16 Aug 2024 12:44:54 +0200 [thread overview]
Message-ID: <cover.1723804990.git.ps@pks.im> (raw)
In-Reply-To: <cover.1723533091.git.ps@pks.im>
Hi,
this is the second version of my patch series that fixes how
git-maintenance(1) detaches: instead of letting its child process
git-gc(1) detach, we now optionally ask git-maintenance(1) itself to
detach when running via our auto maintenance mechanism. This fixes
behaviour of git-maintenance(1) when configured to run non-standard
tasks like the "incremental" task.
Changes compared to v2:
- Fix leaking git-gc(1) process in t6500.
- Add missing documentation for `maintenance.autoDetach`.
Thanks!
Patrick
Patrick Steinhardt (7):
config: fix constness of out parameter for `git_config_get_expiry()`
builtin/gc: refactor to read config into structure
builtin/gc: fix leaking config values
builtin/gc: stop processing log file on signal
builtin/gc: add a `--detach` flag
builtin/maintenance: add a `--detach` flag
run-command: fix detaching when running auto maintenance
Documentation/config/gc.txt | 3 +-
Documentation/config/maintenance.txt | 11 +
Documentation/git-gc.txt | 5 +-
builtin/gc.c | 384 +++++++++++++++++----------
config.c | 4 +-
config.h | 2 +-
read-cache.c | 12 +-
run-command.c | 12 +-
t/t5304-prune.sh | 1 +
t/t5616-partial-clone.sh | 6 +-
t/t6500-gc.sh | 45 +++-
t/t7900-maintenance.sh | 82 +++++-
12 files changed, 396 insertions(+), 171 deletions(-)
Range-diff against v2:
1: 040453f27f = 1: 040453f27f config: fix constness of out parameter for `git_config_get_expiry()`
2: ff6aa9d7ba = 2: ff6aa9d7ba builtin/gc: refactor to read config into structure
3: 310e361371 = 3: 310e361371 builtin/gc: fix leaking config values
4: 812c61c9b6 = 4: 812c61c9b6 builtin/gc: stop processing log file on signal
5: ca78d3dc7c ! 5: b934b23889 builtin/gc: add a `--detach` flag
@@ builtin/gc.c: static int maintenance_run(int argc, const char **argv, const char
for (i = 0; i < TASK__COUNT; i++)
## t/t6500-gc.sh ##
+@@ t/t6500-gc.sh: test_expect_success 'gc.maxCruftSize sets appropriate repack options' '
+ test_subcommand $cruft_max_size_opts --max-cruft-size=3145728 <trace2.txt
+ '
+
+-run_and_wait_for_auto_gc () {
++run_and_wait_for_gc () {
+ # We read stdout from gc for the side effect of waiting until the
+ # background gc process exits, closing its fd 9. Furthermore, the
+ # variable assignment from a command substitution preserves the
+ # exit status of the main gc process.
+ # Note: this fd trickery doesn't work on Windows, but there is no
+ # need to, because on Win the auto gc always runs in the foreground.
+- doesnt_matter=$(git gc --auto 9>&1)
++ doesnt_matter=$(git gc "$@" 9>&1)
+ }
+
+ test_expect_success 'background auto gc does not run if gc.log is present and recent but does if it is old' '
+@@ t/t6500-gc.sh: test_expect_success 'background auto gc does not run if gc.log is present and re
+ test-tool chmtime =-345600 .git/gc.log &&
+ git gc --auto &&
+ test_config gc.logexpiry 2.days &&
+- run_and_wait_for_auto_gc &&
++ run_and_wait_for_gc --auto &&
+ ls .git/objects/pack/pack-*.pack >packs &&
+ test_line_count = 1 packs
+ '
@@ t/t6500-gc.sh: test_expect_success 'background auto gc respects lock for all operations' '
+ printf "%d %s" "$shell_pid" "$hostname" >.git/gc.pid &&
+
+ # our gc should exit zero without doing anything
+- run_and_wait_for_auto_gc &&
++ run_and_wait_for_gc --auto &&
+ (ls -1 .git/refs/heads .git/reftable >actual || true) &&
test_cmp expect actual
'
@@ t/t6500-gc.sh: test_expect_success 'background auto gc respects lock for all ope
+ git config gc.autodetach false &&
+ git config gc.auto 2 &&
+
-+ cat >expect <<-EOF &&
-+ Auto packing the repository in background for optimum performance.
-+ See "git help gc" for manual housekeeping.
-+ EOF
-+ GIT_PROGRESS_DELAY=0 git gc --auto --detach 2>actual &&
-+ test_cmp expect actual
++ # Note that we cannot use `test_cmp` here to compare stderr
++ # because it may contain output from `set -x`.
++ run_and_wait_for_gc --auto --detach 2>actual &&
++ test_grep "Auto packing the repository in background for optimum performance." actual
+ )
+'
+
6: 06dbb73425 = 6: 347d0a2002 builtin/maintenance: add a `--detach` flag
7: 6bc170ff05 ! 7: 9befef7c1f run-command: fix detaching when running auto maintenance
@@ Commit message
Signed-off-by: Patrick Steinhardt <ps@pks.im>
+ ## Documentation/config/gc.txt ##
+@@ Documentation/config/gc.txt: use, it'll affect how the auto pack limit works.
+
+ gc.autoDetach::
+ Make `git gc --auto` return immediately and run in the background
+- if the system supports it. Default is true.
++ if the system supports it. Default is true. This config variable acts
++ as a fallback in case `maintenance.autoDetach` is not set.
+
+ gc.bigPackThreshold::
+ If non-zero, all non-cruft packs larger than this limit are kept
+
+ ## Documentation/config/maintenance.txt ##
+@@ Documentation/config/maintenance.txt: maintenance.auto::
+ `git maintenance run --auto` after doing their normal work. Defaults
+ to true.
+
++maintenance.autoDetach::
++ Many Git commands trigger automatic maintenance after they have
++ written data into the repository. This boolean config option
++ controls whether this automatic maintenance shall happen in the
++ foreground or whether the maintenance process shall detach and
++ continue to run in the background.
+++
++If unset, the value of `gc.autoDetach` is used as a fallback. Defaults
++to true if both are unset, meaning that the maintenance process will
++detach.
++
+ maintenance.strategy::
+ This string config option provides a way to specify one of a few
+ recommended schedules for background maintenance. This only affects
+
## builtin/gc.c ##
@@ builtin/gc.c: static int maintenance_task_gc(struct maintenance_run_opts *opts,
strvec_push(&child.args, "--quiet");
--
2.46.0.46.g406f326d27.dirty
next prev parent reply other threads:[~2024-08-16 10:44 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 7:17 [PATCH 0/7] builtin/maintenance: fix auto-detach with non-standard tasks Patrick Steinhardt
2024-08-13 7:17 ` [PATCH 1/7] config: fix constness of out parameter for `git_config_get_expiry()` Patrick Steinhardt
2024-08-13 7:17 ` [PATCH 2/7] builtin/gc: refactor to read config into structure Patrick Steinhardt
2024-08-15 5:24 ` James Liu
2024-08-15 8:18 ` Patrick Steinhardt
2024-08-15 13:46 ` Derrick Stolee
2024-08-13 7:17 ` [PATCH 3/7] builtin/gc: fix leaking config values Patrick Steinhardt
2024-08-15 5:22 ` James Liu
2024-08-15 8:18 ` Patrick Steinhardt
2024-08-15 13:50 ` Derrick Stolee
2024-08-13 7:17 ` [PATCH 4/7] builtin/gc: stop processing log file on signal Patrick Steinhardt
2024-08-15 6:01 ` James Liu
2024-08-13 7:17 ` [PATCH 5/7] builtin/gc: add a `--detach` flag Patrick Steinhardt
2024-08-13 7:17 ` [PATCH 6/7] builtin/maintenance: " Patrick Steinhardt
2024-08-13 7:18 ` [PATCH 7/7] builtin/maintenance: fix auto-detach with non-standard tasks Patrick Steinhardt
2024-08-13 11:29 ` Phillip Wood
2024-08-13 11:59 ` Patrick Steinhardt
2024-08-13 13:19 ` Phillip Wood
2024-08-14 4:15 ` Patrick Steinhardt
2024-08-14 15:13 ` Phillip Wood
2024-08-15 5:30 ` Patrick Steinhardt
2024-08-15 6:40 ` James Liu
2024-08-15 8:17 ` Patrick Steinhardt
2024-08-15 14:00 ` Derrick Stolee
2024-08-15 6:42 ` [PATCH 0/7] " James Liu
2024-08-15 9:12 ` [PATCH v2 " Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 1/7] config: fix constness of out parameter for `git_config_get_expiry()` Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 2/7] builtin/gc: refactor to read config into structure Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 3/7] builtin/gc: fix leaking config values Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 4/7] builtin/gc: stop processing log file on signal Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 5/7] builtin/gc: add a `--detach` flag Patrick Steinhardt
2024-08-15 19:11 ` Junio C Hamano
2024-08-15 22:29 ` Junio C Hamano
2024-08-16 8:06 ` Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 6/7] builtin/maintenance: " Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 7/7] run-command: fix detaching when running auto maintenance Patrick Steinhardt
2024-08-15 16:13 ` Junio C Hamano
2024-08-16 8:06 ` Patrick Steinhardt
2024-08-15 14:04 ` [PATCH 0/7] builtin/maintenance: fix auto-detach with non-standard tasks Derrick Stolee
2024-08-15 15:37 ` Junio C Hamano
2024-08-16 8:06 ` Patrick Steinhardt
2024-08-16 10:44 ` Patrick Steinhardt [this message]
2024-08-16 10:44 ` [PATCH v3 1/7] config: fix constness of out parameter for `git_config_get_expiry()` Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 2/7] builtin/gc: refactor to read config into structure Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 3/7] builtin/gc: fix leaking config values Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 4/7] builtin/gc: stop processing log file on signal Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 5/7] builtin/gc: add a `--detach` flag Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 6/7] builtin/maintenance: " Patrick Steinhardt
2024-08-17 7:09 ` Jeff King
2024-08-17 7:14 ` Jeff King
2024-08-19 6:17 ` Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 7/7] run-command: fix detaching when running auto maintenance Patrick Steinhardt
2024-08-17 12:14 ` Jeff King
2024-08-19 6:17 ` Patrick Steinhardt
2024-08-19 7:47 ` [PATCH 0/3] Fixups for git-maintenance(1) tests Patrick Steinhardt
2024-08-19 7:47 ` [PATCH 1/3] t7900: fix flaky test due to leaking background job Patrick Steinhardt
2024-08-19 8:49 ` Jeff King
2024-08-19 8:55 ` Patrick Steinhardt
2024-08-19 9:12 ` Jeff King
2024-08-19 9:17 ` Patrick Steinhardt
2024-08-19 7:48 ` [PATCH 2/3] t7900: exercise detaching via trace2 regions Patrick Steinhardt
2024-08-19 8:51 ` Jeff King
2024-08-19 8:56 ` Patrick Steinhardt
2024-08-21 18:38 ` Junio C Hamano
2024-08-22 5:41 ` Patrick Steinhardt
2024-08-22 17:22 ` Junio C Hamano
2024-08-19 7:48 ` [PATCH 3/3] builtin/maintenance: fix loose objects task emitting pack hash Patrick Steinhardt
2024-08-19 8:55 ` Jeff King
2024-08-19 9:07 ` Patrick Steinhardt
2024-08-19 9:17 ` Jeff King
2024-08-19 9:26 ` Patrick Steinhardt
2024-08-19 10:26 ` Jeff King
2024-08-20 7:39 ` Patrick Steinhardt
2024-08-20 15:58 ` Junio C Hamano
2024-08-19 17:05 ` Junio C Hamano
2024-08-19 8:46 ` [PATCH v3 7/7] run-command: fix detaching when running auto maintenance Jeff King
2024-08-19 9:04 ` Patrick Steinhardt
2024-08-19 10:49 ` Patrick Steinhardt
2024-08-19 15:41 ` Patrick Steinhardt
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=cover.1723804990.git.ps@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=james@jamesliu.io \
--cc=phillip.wood123@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=stolee@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).