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 07/15] run-command API: make "jobs" parameter an "unsigned int"
Date: Fri, 7 Oct 2022 10:53:07 +0100 [thread overview]
Message-ID: <04f23267-b495-cf7c-f0e3-4e49768fb077@gmail.com> (raw)
In-Reply-To: <patch-07.15-a9810aaa852-20220930T111343Z-avarab@gmail.com>
On 30/09/2022 12:28, Ævar Arnfjörð Bjarmason wrote:
> The rename the "n" variable added in c553c72eed6 (run-command: add an
> asynchronous parallel child processor, 2015-12-15) to "jobs", and
> change the type to an "unsigned int". As we'll see in a subsequent
> commit we do pass "0" here, but never "jobs < 0".
>
> The only users of the "jobs" parameter are:
>
> * builtin/fetch.c: defaults to 1, reads from the "fetch.parallel"
> config. As seen in the code that parses the config added in
> d54dea77dba (fetch: let --jobs=<n> parallelize --multiple, too,
> 2019-10-05) will die if the git_config_int() return value is < 0.
>
> It will however pass us jobs = 0, as we'll see in a subsequent
> commit.
>
> * submodule.c: defaults to 1, reads from "submodule.fetchJobs"
> config. Read via code originally added in a028a1930c6 (fetching
> submodules: respect `submodule.fetchJobs` config option, 2016-02-29).
>
> It now piggy-backs on the the submodule.fetchJobs code and
> validation added in f20e7c1ea24 (submodule: remove
> submodule.fetchjobs from submodule-config parsing, 2017-08-02).
>
> Like builtin/fetch.c it will die if the git_config_int() return
> value is < 0, but like builtin/fetch.c it will pass us jobs = 0.
>
> * builtin/submodule--helper.c: defaults to 1. Read via code
> originally added in 2335b870fa7 (submodule update: expose parallelism
> to the user, 2016-02-29).
>
> Since f20e7c1ea24 (submodule: remove submodule.fetchjobs from
> submodule-config parsing, 2017-08-02) it shares a config parser and
> semantics with the submodule.c caller.
>
> * hook.c: hardcoded to 1, see 96e7225b310 (hook: add 'run'
> subcommand, 2021-12-22).
>
> * t/helper/test-run-command.c: can be -1 after parsing the arguments,
> but will then be overridden to online_cpus() before passing it to
> this API. See be5d88e1128 (test-tool run-command: learn to run (parts
> of) the testsuite, 2019-10-04).
I'm afraid I think this commit is a complete waste of reviewers time. As
far as I con see in a later commit all the changes here are rewritten.
Why do we need to go from n -> jobs -> opts->jobs rather than just n ->
opts->jobs later.
Best Wishes
Phillip
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> run-command.c | 33 +++++++++++++++++----------------
> run-command.h | 6 +++---
> 2 files changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/run-command.c b/run-command.c
> index 642e6b6e057..80d282dbdb6 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -1500,8 +1500,8 @@ int run_processes_parallel_ungroup;
> struct parallel_processes {
> void *data;
>
> - int max_processes;
> - int nr_processes;
> + unsigned int max_processes;
> + unsigned int nr_processes;
>
> get_next_task_fn get_next_task;
> start_failure_fn start_failure;
> @@ -1560,20 +1560,21 @@ static void handle_children_on_signal(int signo)
> }
>
> static void pp_init(struct parallel_processes *pp,
> - int n,
> + unsigned int jobs,
> get_next_task_fn get_next_task,
> start_failure_fn start_failure,
> task_finished_fn task_finished,
> void *data, int ungroup)
> {
> - int i;
> + unsigned int i;
>
> - if (n < 1)
> - n = online_cpus();
> + if (jobs < 1)
> + jobs = online_cpus();
>
> - pp->max_processes = n;
> + pp->max_processes = jobs;
>
> - trace_printf("run_processes_parallel: preparing to run up to %d tasks", n);
> + trace_printf("run_processes_parallel: preparing to run up to %d tasks",
> + jobs);
>
> pp->data = data;
> if (!get_next_task)
> @@ -1587,14 +1588,14 @@ static void pp_init(struct parallel_processes *pp,
> pp->output_owner = 0;
> pp->shutdown = 0;
> pp->ungroup = ungroup;
> - CALLOC_ARRAY(pp->children, n);
> + CALLOC_ARRAY(pp->children, jobs);
> if (pp->ungroup)
> pp->pfd = NULL;
> else
> - CALLOC_ARRAY(pp->pfd, n);
> + CALLOC_ARRAY(pp->pfd, jobs);
> strbuf_init(&pp->buffered_output, 0);
>
> - for (i = 0; i < n; i++) {
> + for (i = 0; i < jobs; i++) {
> strbuf_init(&pp->children[i].err, 0);
> child_process_init(&pp->children[i].process);
> if (pp->pfd) {
> @@ -1783,7 +1784,7 @@ static int pp_collect_finished(struct parallel_processes *pp)
> return result;
> }
>
> -void run_processes_parallel(int n,
> +void run_processes_parallel(unsigned int jobs,
> get_next_task_fn get_next_task,
> start_failure_fn start_failure,
> task_finished_fn task_finished,
> @@ -1798,7 +1799,7 @@ void run_processes_parallel(int n,
> /* unset for the next API user */
> run_processes_parallel_ungroup = 0;
>
> - pp_init(&pp, n, get_next_task, start_failure, task_finished, pp_cb,
> + pp_init(&pp, jobs, get_next_task, start_failure, task_finished, pp_cb,
> ungroup);
> while (1) {
> for (i = 0;
> @@ -1836,15 +1837,15 @@ void run_processes_parallel(int n,
> pp_cleanup(&pp);
> }
>
> -void run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
> +void run_processes_parallel_tr2(unsigned int jobs, get_next_task_fn get_next_task,
> start_failure_fn start_failure,
> task_finished_fn task_finished, void *pp_cb,
> const char *tr2_category, const char *tr2_label)
> {
> trace2_region_enter_printf(tr2_category, tr2_label, NULL, "max:%d",
> - ((n < 1) ? online_cpus() : n));
> + ((jobs < 1) ? online_cpus() : jobs));
>
> - run_processes_parallel(n, get_next_task, start_failure,
> + run_processes_parallel(jobs, get_next_task, start_failure,
> task_finished, pp_cb);
>
> trace2_region_leave(tr2_category, tr2_label, NULL);
> diff --git a/run-command.h b/run-command.h
> index e76a1b6b5b3..4502bdc64dc 100644
> --- a/run-command.h
> +++ b/run-command.h
> @@ -459,7 +459,7 @@ typedef int (*task_finished_fn)(int result,
> void *pp_task_cb);
>
> /**
> - * Runs up to n processes at the same time. Whenever a process can be
> + * Runs up to 'jobs' processes at the same time. Whenever a process can be
> * started, the callback get_next_task_fn is called to obtain the data
> * required to start another child process.
> *
> @@ -485,12 +485,12 @@ typedef int (*task_finished_fn)(int result,
> * API reads that setting.
> */
> extern int run_processes_parallel_ungroup;
> -void run_processes_parallel(int n,
> +void run_processes_parallel(unsigned int jobs,
> get_next_task_fn,
> start_failure_fn,
> task_finished_fn,
> void *pp_cb);
> -void run_processes_parallel_tr2(int n, get_next_task_fn, start_failure_fn,
> +void run_processes_parallel_tr2(unsigned int jobs, get_next_task_fn, start_failure_fn,
> task_finished_fn, void *pp_cb,
> const char *tr2_category, const char *tr2_label);
>
next prev parent reply other threads:[~2022-10-07 9:53 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 [this message]
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
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=04f23267-b495-cf7c-f0e3-4e49768fb077@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).