From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Calvin Wan" <calvinwan@google.com>,
"Emily Shaffer" <emilyshaffer@google.com>,
"Phillip Wood" <phillip.wood123@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v3 08/15] run-command API: move *_tr2() users to "run_processes_parallel()"
Date: Wed, 12 Oct 2022 23:02:27 +0200 [thread overview]
Message-ID: <patch-v3-08.15-c19c60b2e95-20221012T205712Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v3-00.15-00000000000-20221012T205712Z-avarab@gmail.com>
Have the users of the "run_processes_parallel_tr2()" function use
"run_processes_parallel()" instead. In preceding commits the latter
was refactored to take a "struct run_process_parallel_opts" argument,
since the only reason for "run_processes_parallel_tr2()" to exist was
to take arguments that are now a part of that struct we can do away
with it.
See ee4512ed481 (trace2: create new combined trace facility,
2019-02-22) for the addition of the "*_tr2()" variant of the function,
it was used by every caller except "t/helper/test-run-command.c"..
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
builtin/fetch.c | 18 ++++++++++++------
builtin/submodule--helper.c | 16 ++++++++++++----
run-command.c | 18 ------------------
run-command.h | 3 ---
submodule.c | 18 ++++++++++++------
5 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 82f1da14ec1..b06e454cbdd 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1953,15 +1953,21 @@ static int fetch_multiple(struct string_list *list, int max_children)
if (max_children != 1 && list->nr != 1) {
struct parallel_fetch_state state = { argv.v, list, 0, 0 };
+ const struct run_process_parallel_opts opts = {
+ .tr2_category = "fetch",
+ .tr2_label = "parallel/fetch",
+
+ .processes = max_children,
+
+ .get_next_task = &fetch_next_remote,
+ .start_failure = &fetch_failed_to_start,
+ .task_finished = &fetch_finished,
+ .data = &state,
+ };
strvec_push(&argv, "--end-of-options");
- run_processes_parallel_tr2(max_children,
- &fetch_next_remote,
- &fetch_failed_to_start,
- &fetch_finished,
- &state,
- "fetch", "parallel/fetch");
+ run_processes_parallel(&opts);
result = state.result;
} else
for (i = 0; i < list->nr; i++) {
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 0b4acb442b2..df526525c1e 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2567,12 +2567,20 @@ static int update_submodules(struct update_data *update_data)
{
int i, ret = 0;
struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT;
+ const struct run_process_parallel_opts opts = {
+ .tr2_category = "submodule",
+ .tr2_label = "parallel/update",
+
+ .processes = 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,
+ };
suc.update_data = update_data;
- 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);
/*
* We saved the output and put it out all at once now.
diff --git a/run-command.c b/run-command.c
index 2858ec7bef5..646ea22e399 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1827,24 +1827,6 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
trace2_region_leave(tr2_category, tr2_label, NULL);
}
-void run_processes_parallel_tr2(size_t processes, 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)
-{
- const struct run_process_parallel_opts opts = {
- .tr2_category = tr2_category,
- .tr2_label = tr2_label,
- .processes = processes,
-
- .get_next_task = get_next_task,
- .start_failure = start_failure,
- .task_finished = task_finished,
- };
-
- run_processes_parallel(&opts);
-}
-
int run_auto_maintenance(int quiet)
{
int enabled;
diff --git a/run-command.h b/run-command.h
index aabdaf684db..e3e1ea01ad9 100644
--- a/run-command.h
+++ b/run-command.h
@@ -528,9 +528,6 @@ struct run_process_parallel_opts
* conditions due to writing in parallel to stdout and stderr.
*/
void run_processes_parallel(const struct run_process_parallel_opts *opts);
-void run_processes_parallel_tr2(size_t processes, get_next_task_fn,
- start_failure_fn, task_finished_fn, void *pp_cb,
- const char *tr2_category, const char *tr2_label);
/**
* Convenience function which prepares env for a command to be run in a
diff --git a/submodule.c b/submodule.c
index bf7a2c79183..f7c71f1f4b1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1819,6 +1819,17 @@ int fetch_submodules(struct repository *r,
{
int i;
struct submodule_parallel_fetch spf = SPF_INIT;
+ const struct run_process_parallel_opts opts = {
+ .tr2_category = "submodule",
+ .tr2_label = "parallel/fetch",
+
+ .processes = max_parallel_jobs,
+
+ .get_next_task = get_next_submodule,
+ .start_failure = fetch_start_failure,
+ .task_finished = fetch_finish,
+ .data = &spf,
+ };
spf.r = r;
spf.command_line_option = command_line_option;
@@ -1840,12 +1851,7 @@ int fetch_submodules(struct repository *r,
calculate_changed_submodule_paths(r, &spf.changed_submodule_names);
string_list_sort(&spf.changed_submodule_names);
- run_processes_parallel_tr2(max_parallel_jobs,
- get_next_submodule,
- fetch_start_failure,
- fetch_finish,
- &spf,
- "submodule", "parallel/fetch");
+ run_processes_parallel(&opts);
if (spf.submodules_with_errors.len > 0)
fprintf(stderr, _("Errors during submodule fetch:\n%s"),
--
2.38.0.971.ge79ff6d20e7
next prev parent reply other threads:[~2022-10-12 21:04 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
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 ` Ævar Arnfjörð Bjarmason [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=patch-v3-08.15-c19c60b2e95-20221012T205712Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=calvinwan@google.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood123@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).