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

Re: [PATCH v2 2/5] fetch: Add the "--fetch-jobs" option

From
EWEric Wong <e@80x24.org>
Date
Aug 13, 2019, 14:44 UTC
Message-ID
<20190813144441.qw5i3zbrvebz5o7z@dcvr>
In-Reply-To
<20190812213448.2649-3-palmer@sifive.com>
Palmer Dabbelt <palmer@sifive.com> wrote:
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 8aa6a0caf1ab..fa12ad44e7d9 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
<snip>
Show 30 quoted lines
> +static int next_remote_to_fetch(struct child_process *cp,
> +				struct strbuf *out,
> +				void *state_uncast,
> +				void **task_state_out)
> +{
> +	int i;
> +	struct fetch_remote *state = state_uncast;
> +	struct fetch_remote_task *task_state = NULL;
> +	const char *remote_name;
> +
> +	if (state->next_remote_index >= state->all_remotes->nr)
> +		return 0;
> +
> +	remote_name = state->all_remotes->items[state->next_remote_index].string;
> +	state->next_remote_index++;
> +
> +	/*
> +	 * Finds somewhere to store the state for a task.  This is guarnteed to
> +	 * succeed because there are always enough tasks allocated to cover the
> +	 * number that have been requested to run in parallel.  Rather than
> +	 * bothering with some sort of free list, this just brute force
> +	 * searches for a free task.  The assumption is that there aren't that
> +	 * many tasks to look through.
> +	 */
> +	for (i = 0; i < state->task_count; ++i) {
> +		if (!state->all_tasks[i].in_use) {
> +			task_state = state->all_tasks + i;
> +			break;
> +		}
> +	}

Fwiw, I added list.h, the linked-list derived from the Linux kernel to simplify usage of free lists, queues, etc...

I think it could improve readability, too; but I'm not really a C programmer and prefer high-level scripting languages.

Previous: Palmer DabbeltNext: Palmer Dabbelt
Message 4 of 14 in “fetch: Extend --jobs to multiple remotes”
  1. 0/5 fetch: Extend --jobs to multiple remotesPalmer Dabbelt, Aug 12, 2019
  2. 1/5 fetch: Rename max_children to max_children_for_submodulesPalmer Dabbelt, Aug 12, 2019
  3. 2/5 fetch: Add the "--fetch-jobs" optionPalmer Dabbelt, Aug 12, 2019
  4. Eric WongAug 13, 2019
  5. 3/5 fetch: Add the fetch.jobs config keyPalmer Dabbelt, Aug 12, 2019
  6. 4/5 fetch: Add the --submodule-fetch-jobs optionPalmer Dabbelt, Aug 12, 2019
  7. 5/5 fetch: Make --jobs control submodules and remotesPalmer Dabbelt, Aug 12, 2019
  8. Johannes SchindelinAug 13, 2019
  9. Palmer DabbeltAug 13, 2019
  10. Junio C HamanoAug 13, 2019
  11. Palmer DabbeltAug 13, 2019
  12. SZEDER GáborAug 14, 2019
  13. Junio C HamanoAug 14, 2019
  14. Palmer DabbeltAug 14, 2019

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.