git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv7 0/8] fetch submodules in parallel

From
Stefan Beller <sbeller@google.com>
Date
Oct 12, 2015, 18:47 UTC
Message-ID
<1444675641-14866-1-git-send-email-sbeller@google.com>
fixing two smaller nits noticed by Ramsay
 * make struct parallel_processes static
 * omit the forward declaration of get_next_submodule by reordering.
Jonathan Nieder (1):
  submodule.c: write "Fetching submodule <foo>" to stderr
Stefan Beller (7):
  xread: poll on non blocking fds
  xread_nonblock: add functionality to read from fds without blocking
  strbuf: add strbuf_read_once to read without blocking
  sigchain: add command to pop all common signals
  run-command: add an asynchronous parallel child processor
  fetch_populated_submodules: use new parallel job processing
  submodules: allow parallel fetching, add tests and documentation
 Documentation/fetch-options.txt |   7 +
 builtin/fetch.c                 |   6 +-
 builtin/pull.c                  |   6 +
 git-compat-util.h               |   1 +
 run-command.c                   | 350 ++++++++++++++++++++++++++++++++++++++++
 run-command.h                   |  78 +++++++++
 sigchain.c                      |   9 ++
 sigchain.h                      |   1 +
 strbuf.c                        |  11 ++
 strbuf.h                        |   9 ++
 submodule.c                     | 144 ++++++++++++-----
 submodule.h                     |   2 +-
 t/t0061-run-command.sh          |  20 +++
 t/t5526-fetch-submodules.sh     |  70 +++++---
 test-run-command.c              |  25 +++
 wrapper.c                       |  35 +++-
 16 files changed, 701 insertions(+), 73 deletions(-)
 $ git diff origin/sb/submodule-parallel-fetch
diff --git a/run-command.c b/run-command.c
index 28048a7..ef3da27 100644
--- a/run-command.c
+++ b/run-command.c
@@ -855,7 +855,7 @@ int capture_command(struct child_process *cmd, struct strbuf *buf, size_t hint)
 	return finish_command(cmd);
 }
 
-struct parallel_processes {
+static struct parallel_processes {
 	void *data;
 
 	int max_processes;
diff --git a/submodule.c b/submodule.c
index cf8bf5d..c21b265 100644
--- a/submodule.c
+++ b/submodule.c
@@ -628,68 +628,6 @@ struct submodule_parallel_fetch {
 #define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0}
 
 static int get_next_submodule(void **task_cb, struct child_process *cp,
-			      struct strbuf *err, void *data);
-
-static int fetch_start_failure(struct child_process *cp,
-			       struct strbuf *err,
-			       void *cb, void *task_cb)
-{
-	struct submodule_parallel_fetch *spf = cb;
-
-	spf->result = 1;
-
-	return 0;
-}
-
-static int fetch_finish(int retvalue, struct child_process *cp,
-			struct strbuf *err, void *cb, void *task_cb)
-{
-	struct submodule_parallel_fetch *spf = cb;
-
-	if (retvalue)
-		spf->result = 1;
-
-	return 0;
-}
-
-int fetch_populated_submodules(const struct argv_array *options,
-			       const char *prefix, int command_line_option,
-			       int quiet, int max_parallel_jobs)
-{
-	int i;
-	struct submodule_parallel_fetch spf = SPF_INIT;
-
-	spf.work_tree = get_git_work_tree();
-	spf.command_line_option = command_line_option;
-	spf.quiet = quiet;
-	spf.prefix = prefix;
-
-	if (!spf.work_tree)
-		goto out;
-
-	if (read_cache() < 0)
-		die("index file corrupt");
-
-	argv_array_push(&spf.args, "fetch");
-	for (i = 0; i < options->argc; i++)
-		argv_array_push(&spf.args, options->argv[i]);
-	argv_array_push(&spf.args, "--recurse-submodules-default");
-	/* default value, "--submodule-prefix" and its value are added later */
-
-	calculate_changed_submodule_paths();
-	run_processes_parallel(max_parallel_jobs,
-			       get_next_submodule,
-			       fetch_start_failure,
-			       fetch_finish,
-			       &spf);
-
-	argv_array_clear(&spf.args);
-out:
-	string_list_clear(&changed_submodule_paths, 1);
-	return spf.result;
-}
-
-static int get_next_submodule(void **task_cb, struct child_process *cp,
 			      struct strbuf *err, void *data)
 {
 	int ret = 0;
@@ -775,6 +713,65 @@ static int get_next_submodule(void **task_cb, struct child_process *cp,
 	return 0;
 }
 
+static int fetch_start_failure(struct child_process *cp,
+			       struct strbuf *err,
+			       void *cb, void *task_cb)
+{
+	struct submodule_parallel_fetch *spf = cb;
+
+	spf->result = 1;
+
+	return 0;
+}
+
+static int fetch_finish(int retvalue, struct child_process *cp,
+			struct strbuf *err, void *cb, void *task_cb)
+{
+	struct submodule_parallel_fetch *spf = cb;
+
+	if (retvalue)
+		spf->result = 1;
+
+	return 0;
+}
+
+int fetch_populated_submodules(const struct argv_array *options,
+			       const char *prefix, int command_line_option,
+			       int quiet, int max_parallel_jobs)
+{
+	int i;
+	struct submodule_parallel_fetch spf = SPF_INIT;
+
+	spf.work_tree = get_git_work_tree();
+	spf.command_line_option = command_line_option;
+	spf.quiet = quiet;
+	spf.prefix = prefix;
+
+	if (!spf.work_tree)
+		goto out;
+
+	if (read_cache() < 0)
+		die("index file corrupt");
+
+	argv_array_push(&spf.args, "fetch");
+	for (i = 0; i < options->argc; i++)
+		argv_array_push(&spf.args, options->argv[i]);
+	argv_array_push(&spf.args, "--recurse-submodules-default");
+	/* default value, "--submodule-prefix" and its value are added later */
+
+	calculate_changed_submodule_paths();
+	run_processes_parallel(max_parallel_jobs,
+			       get_next_submodule,
+			       fetch_start_failure,
+			       fetch_finish,
+			       &spf);
+
+	argv_array_clear(&spf.args);
+out:
+	string_list_clear(&changed_submodule_paths, 1);
+	return spf.result;
+}
+
 unsigned is_submodule_modified(const char *path, int ignore_untracked)
 {
 	ssize_t len;
-- 
2.5.0.268.g453a26a
Next: Stefan Beller
Message 1 of 10 in “[PATCHv7 0/8] fetch submodules in parallel”
  1. Stefan BellerOct 12, 2015
  2. 1/8 submodule.c: write "Fetching submodule <foo>" to stderrStefan Beller, Oct 12, 2015
  3. 2/8 xread: poll on non blocking fdsStefan Beller, Oct 12, 2015
  4. 3/8 xread_nonblock: add functionality to read from fds without blockingStefan Beller, Oct 12, 2015
  5. 4/8 strbuf: add strbuf_read_once to read without blockingStefan Beller, Oct 12, 2015
  6. 5/8 sigchain: add command to pop all common signalsStefan Beller, Oct 12, 2015
  7. 6/8 run-command: add an asynchronous parallel child processorStefan Beller, Oct 12, 2015
  8. 7/8 fetch_populated_submodules: use new parallel job processingStefan Beller, Oct 12, 2015
  9. 8/8 submodules: allow parallel fetching, add tests and documentationStefan Beller, Oct 12, 2015
  10. Junio C HamanoOct 12, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.