git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>, git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Calvin Wan <calvinwan@google.com>,
	Emily Shaffer <emilyshaffer@google.com>
Subject: Re: [PATCH 00/15] run-command API: pass functions & opts via struct
Date: Fri, 7 Oct 2022 10:59:45 +0100	[thread overview]
Message-ID: <52ca644a-0719-0ee6-56bd-a4b2686ae204@gmail.com> (raw)
In-Reply-To: <cover-00.15-00000000000-20220930T111343Z-avarab@gmail.com>

On 30/09/2022 12:27, Ævar Arnfjörð Bjarmason wrote:
> This series changes the run-command API so that we pass options via a
> struct instead of via the argument list, the end result is that an API
> user looks like e.g.:
> 	
> 	+       const struct run_process_parallel_opts opts = {
> 	+               .tr2_category = "submodule",
> 	+               .tr2_label = "parallel/update",
> 	+
> 	+               .jobs = update_data->max_jobs,
> 	+
> 	+               .get_next_task = update_clone_get_next_task,
> 	+               .start_failure = update_clone_start_failure,
> 	+               .task_finished = update_clone_task_finished,
> 	+               .data = &suc,
> 	+       };
> 	[...]
> 	-       run_processes_parallel_tr2(suc.update_data->max_jobs, update_clone_get_next_task,
> 	-                                  update_clone_start_failure,
> 	-                                  update_clone_task_finished, &suc, "submodule",
> 	-                                  "parallel/update");
> 	+       run_processes_parallel(&opts);
> 

Overall this looks good, I've left a few comments as I feel some of the 
patches are either redundant or could be helpfully squashed into an 
adjacent patch to reduce the amount of churn within this series.

Best Wishes

Phillip

> These patches are derived from earlier patches I sent for passing the
> the "ungroup" parameter to this API[1], that's currently done with a
> global variable, because we needed a minimal change for a regression
> fix.
> 
> I'm submitting this now in the rc phase because there's another
> concurrent series that could make use of this[2]. The alternative
> would be for it to add an extra parameter to the two functions (one
> after this series).
> 
> The upcoming migration to the new hook API and config-based hooks[3]
> will also benefit significantly from this. I have a version of that
> topic rebased on top of this, having this first gets rid of a lot of
> churn, adding an optional callback just requires adding things to the
> struct introduced here, not changing every single caller.
> 
> (Passing) CI at:
> https://github.com/avar/git/tree/avar/hook-run-process-parallel-tty-regression-2-argument-passing
> 
> 1. https://lore.kernel.org/git/cover-v3-0.2-00000000000-20220527T090618Z-avarab@gmail.com/
> 2. https://lore.kernel.org/git/20220922232947.631309-1-calvinwan@google.com/
> 3. https://lore.kernel.org/git/cover-v5-00.36-00000000000-20210902T125110Z-avarab@gmail.com/
> 
> Brief commentary on individual patches below:
> 
> Ævar Arnfjörð Bjarmason (15):
>    hook tests: fix redirection logic error in 96e7225b310
>    submodule tests: reset "trace.out" between "grep" invocations
> 
> These bugfixes could be split out I suppose, but since we're changing
> this area 1/15 seemed prudent, 2/15 is required for a later test
> addition
> 
>    run-command tests: test stdout of run_command_parallel()
> 
> Tighten up tests, was ejected from the "ungroup" topic.
> 
>    run-command test helper: use "else if" pattern
>    run-command tests: use "return", not "exit"
> 
> Just setup for later changes.
> 
>    run-command API: have "run_processes_parallel{,_tr2}()" return void
> 
> Turns out we've never used the boilerplate return value for anything
> useful ever.
> 
>    run-command API: make "jobs" parameter an "unsigned int"
>    run-command API: don't fall back on online_cpus()
> 
> This allows us to make the "opts" struct "const", which helps a lot in
> passing it around later on.
> 
>    run-command.c: add an initializer for "struct parallel_processes"
>    run-command API: add nascent "struct run_process_parallel_opts"
>    run-command API: make run_process_parallel{,_tr2}() thin wrappers
>    run-command API: have run_process_parallel() take an "opts" struct
>    run-command API: move *_tr2() users to "run_processes_parallel()"
> 
> This is arguably one logical change (and at some point I had it as
> such), but as the diff would be really large I've tried to split this
> into easily digestable steps.
> 
>    run-command.c: don't copy *_fn to "struct parallel_processes"
>    run-command.c: don't copy "ungroup" to "struct parallel_processes"
> 
> The only reason for copying various parameters into "struct
> parallel_processes" was because we passed them as positionals, now
> that we have an "opts" struct we can just pass that along instead.
> 
> This leaves the "struct parallel_processes" in run-command.c purely
> for managing our own internal state.
> 
> By avoiding this copying we also cut down a lot on the boilerplate
> needed to add a new parameter.
> 
>   builtin/fetch.c             |  25 +++---
>   builtin/submodule--helper.c |  16 +++-
>   hook.c                      |  23 +++---
>   run-command.c               | 152 ++++++++++++++----------------------
>   run-command.h               |  71 ++++++++++++-----
>   submodule-config.c          |   2 +
>   submodule.c                 |  18 +++--
>   t/helper/test-run-command.c |  77 +++++++++++-------
>   t/t0061-run-command.sh      |  25 +++---
>   t/t1800-hook.sh             |   2 +-
>   t/t5526-fetch-submodules.sh |  16 +++-
>   11 files changed, 247 insertions(+), 180 deletions(-)
> 


  parent reply	other threads:[~2022-10-07  9:59 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 11:27 [PATCH 00/15] run-command API: pass functions & opts via struct Ævar Arnfjörð Bjarmason
2022-09-30 11:27 ` [PATCH 01/15] hook tests: fix redirection logic error in 96e7225b310 Ævar Arnfjörð Bjarmason
2022-09-30 11:27 ` [PATCH 02/15] submodule tests: reset "trace.out" between "grep" invocations Ævar Arnfjörð Bjarmason
2022-09-30 11:28 ` [PATCH 03/15] run-command tests: test stdout of run_command_parallel() Ævar Arnfjörð Bjarmason
2022-09-30 11:28 ` [PATCH 04/15] run-command test helper: use "else if" pattern Ævar Arnfjörð Bjarmason
2022-09-30 11:28 ` [PATCH 05/15] run-command tests: use "return", not "exit" Ævar Arnfjörð Bjarmason
2022-10-07  9:24   ` Phillip Wood
2022-09-30 11:28 ` [PATCH 06/15] run-command API: have "run_processes_parallel{,_tr2}()" return void Ævar Arnfjörð Bjarmason
2022-10-07  9:43   ` Phillip Wood
2022-09-30 11:28 ` [PATCH 07/15] run-command API: make "jobs" parameter an "unsigned int" Ævar Arnfjörð Bjarmason
2022-10-04 17:41   ` Calvin Wan
2022-10-07  9:53   ` Phillip Wood
2022-09-30 11:28 ` [PATCH 08/15] run-command API: don't fall back on online_cpus() Ævar Arnfjörð Bjarmason
2022-10-07  9:51   ` Phillip Wood
2022-09-30 11:28 ` [PATCH 09/15] run-command.c: add an initializer for "struct parallel_processes" Ævar Arnfjörð Bjarmason
2022-09-30 11:28 ` [PATCH 10/15] run-command API: add nascent "struct run_process_parallel_opts" Ævar Arnfjörð Bjarmason
2022-10-07  9:55   ` Phillip Wood
2022-09-30 11:28 ` [PATCH 11/15] run-command API: make run_process_parallel{,_tr2}() thin wrappers Ævar Arnfjörð Bjarmason
2022-09-30 11:28 ` [PATCH 12/15] run-command API: have run_process_parallel() take an "opts" struct Ævar Arnfjörð Bjarmason
2022-09-30 11:28 ` [PATCH 13/15] run-command API: move *_tr2() users to "run_processes_parallel()" Ævar Arnfjörð Bjarmason
2022-09-30 11:28 ` [PATCH 14/15] run-command.c: don't copy *_fn to "struct parallel_processes" Ævar Arnfjörð Bjarmason
2022-09-30 11:28 ` [PATCH 15/15] run-command.c: don't copy "ungroup" " Ævar Arnfjörð Bjarmason
2022-10-04 16:12 ` [PATCH 00/15] run-command API: pass functions & opts via struct Calvin Wan
2022-10-07  9:59 ` Phillip Wood [this message]
2022-10-07 16:46   ` Junio C Hamano
2022-10-12  9:01 ` [PATCH v2 00/22] " Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 01/22] hook tests: fix redirection logic error in 96e7225b310 Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 02/22] submodule tests: reset "trace.out" between "grep" invocations Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 03/22] run-command tests: test stdout of run_command_parallel() Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 04/22] run-command test helper: use "else if" pattern Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 05/22] run-command API: have "run_processes_parallel{,_tr2}()" return void Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 06/22] run-command tests: use "return", not "exit" Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 07/22] run-command.c: remove dead assignment in while-loop Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 08/22] run-command.c: use C99 "for (TYPE VAR = ..." syntax where useful Ævar Arnfjörð Bjarmason
2022-10-12 13:04     ` Phillip Wood
2022-10-12 16:05       ` Junio C Hamano
2022-10-12  9:01   ` [PATCH v2 09/22] run-command API: make "n" parameter a "size_t" Ævar Arnfjörð Bjarmason
2022-10-12 13:09     ` Phillip Wood
2022-10-12  9:01   ` [PATCH v2 10/22] run-command API: don't fall back on online_cpus() Ævar Arnfjörð Bjarmason
2022-10-12 13:14     ` Phillip Wood
2022-10-12  9:01   ` [PATCH v2 11/22] run-command.c: use designated init for pp_init(), add "const" Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 12/22] run-command API: add nascent "struct run_process_parallel_opts" Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 13/22] run-command API: make run_process_parallel{,_tr2}() thin wrappers Ævar Arnfjörð Bjarmason
2022-10-12 13:23     ` Phillip Wood
2022-10-12  9:01   ` [PATCH v2 14/22] run-command API: have run_process_parallel() take an "opts" struct Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 15/22] run-command API: move *_tr2() users to "run_processes_parallel()" Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 16/22] run-command.c: make "struct parallel_processes" const if possible Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 17/22] run-command.c: don't copy *_fn to "struct parallel_processes" Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 18/22] run-command.c: don't copy "ungroup" " Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 19/22] run-command.c: don't copy "data" " Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 20/22] run-command.c: use "opts->processes", not "pp->max_processes" Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 21/22] run-command.c: pass "opts" further down, and use "opts->processes" Ævar Arnfjörð Bjarmason
2022-10-12  9:01   ` [PATCH v2 22/22] run-command.c: remove "pp->max_processes", add "const" to signal() handler Ævar Arnfjörð Bjarmason
2022-10-12 18:58     ` Ævar Arnfjörð Bjarmason
2022-10-12 13:39   ` [PATCH v2 00/22] run-command API: pass functions & opts via struct Phillip Wood
2022-10-12 21:02   ` [PATCH v3 00/15] " Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 01/15] run-command test helper: use "else if" pattern Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 02/15] run-command API: have "run_processes_parallel{,_tr2}()" return void Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 03/15] run-command tests: use "return", not "exit" Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 04/15] run-command API: make "n" parameter a "size_t" Ævar Arnfjörð Bjarmason
2022-10-14  9:30       ` Phillip Wood
2022-10-12 21:02     ` [PATCH v3 05/15] run-command API: don't fall back on online_cpus() Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 06/15] run-command.c: use designated init for pp_init(), add "const" Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 07/15] run-command API: have run_process_parallel() take an "opts" struct Ævar Arnfjörð Bjarmason
2022-10-14  9:50       ` Phillip Wood
2022-10-12 21:02     ` [PATCH v3 08/15] run-command API: move *_tr2() users to "run_processes_parallel()" Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 09/15] run-command.c: make "struct parallel_processes" const if possible Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 10/15] run-command.c: don't copy *_fn to "struct parallel_processes" Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 11/15] run-command.c: don't copy "ungroup" " Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 12/15] run-command.c: don't copy "data" " Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 13/15] run-command.c: use "opts->processes", not "pp->max_processes" Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 14/15] run-command.c: pass "opts" further down, and use "opts->processes" Ævar Arnfjörð Bjarmason
2022-10-12 21:02     ` [PATCH v3 15/15] run-command.c: remove "max_processes", add "const" to signal() handler Ævar Arnfjörð Bjarmason
2022-10-13 22:02       ` Glen Choo
2022-10-13 19:19     ` [PATCH v3 00/15] run-command API: pass functions & opts via struct Calvin Wan
2022-10-13 20:17       ` Junio C Hamano
2022-10-14 10:00     ` Phillip Wood
2022-10-14 14:50       ` Ævar Arnfjörð Bjarmason
2022-10-14 15:53         ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=52ca644a-0719-0ee6-56bd-a4b2686ae204@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=avarab@gmail.com \
    --cc=calvinwan@google.com \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).