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

Re: [PATCH v2 4/7] index-pack: remove redundant child field

From
Josh Steadmon <steadmon@google.com>
Date
Feb 28, 2020, 00:04 UTC
Message-ID
<20200228000437.GD12115@google.com>
In-Reply-To
<3359b66b841e7eabdc45d3d937e97208b22e2901.1571343096.git.jonathantanmy@google.com>
On 2019.10.17 13:17, Jonathan Tan wrote:
Show 37 quoted lines
> @@ -380,27 +378,37 @@ static void free_base_data(struct base_data *c)
>  	}
>  }
>  
> -static void prune_base_data(struct base_data *retain)
> +static void prune_base_data(struct base_data *youngest_child)
>  {
>  	struct base_data *b;
>  	struct thread_local *data = get_thread_data();
> -	for (b = data->base_cache;
> -	     data->base_cache_used > delta_base_cache_limit && b;
> -	     b = b->child) {
> -		if (b->data && b != retain)
> -			free_base_data(b);
> +	struct base_data **ancestry = NULL;
> +	size_t nr = 0, alloc = 0;
> +	ssize_t i;
> +
> +	if (data->base_cache_used <= delta_base_cache_limit)
> +		return;
> +
> +	/*
> +	 * Free all ancestors of youngest_child until we have enough space,
> +	 * starting with the oldest. (We cannot free youngest_child itself.)
> +	 */
> +	for (b = youngest_child->base; b != NULL; b = b->base) {
> +		ALLOC_GROW(ancestry, nr + 1, alloc);
> +		ancestry[nr++] = b;
>  	}
> +	for (i = nr - 1;
> +	     i >= 0 && data->base_cache_used > delta_base_cache_limit;
> +	     i--) {
> +		if (ancestry[i]->data)
> +			free_base_data(ancestry[i]);
> +	}
> +	free(ancestry);
>  }

I had a small complaint that we're allocating new memory in a function where we are trying to free up space, but in practice it probably doesn't matter. And this is removed in a later patch anyway.

Previous: Jonathan TanNext: Jonathan Tan
Message 24 of 31 in “Better threaded delta resolution in index-pack”
  1. 0/6 Better threaded delta resolution in index-packJonathan Tan, Oct 9, 2019
  2. 1/6 index-pack: unify threaded and unthreaded codeJonathan Tan, Oct 9, 2019
  3. Jeff KingOct 17, 2019
  4. 2/6 index-pack: remove redundant parameterJonathan Tan, Oct 9, 2019
  5. Jeff KingOct 17, 2019
  6. 3/6 index-pack: remove redundant child fieldJonathan Tan, Oct 9, 2019
  7. Derrick StoleeOct 10, 2019
  8. Jonathan TanOct 10, 2019
  9. Jeff KingOct 17, 2019
  10. Jeff KingOct 17, 2019
  11. 4/6 index-pack: calculate {ref,ofs}_{first,last} earlyJonathan Tan, Oct 9, 2019
  12. Jeff KingOct 17, 2019
  13. 5/6 index-pack: make resolve_delta() assume base dataJonathan Tan, Oct 9, 2019
  14. Jeff KingOct 17, 2019
  15. 6/6 index-pack: make quantum of work smallerJonathan Tan, Oct 9, 2019
  16. Jeff KingOct 17, 2019
  17. 0/7 Better threaded delta resolution in index-packJonathan Tan, Oct 17, 2019
  18. 1/7 Documentation: deltaBaseCacheLimit is per-threadJonathan Tan, Oct 17, 2019
  19. 3/7 index-pack: remove redundant parameterJonathan Tan, Oct 17, 2019
  20. Josh SteadmonFeb 28, 2020
  21. Jonathan TanMar 10, 2020
  22. 2/7 index-pack: unify threaded and unthreaded codeJonathan Tan, Oct 17, 2019
  23. 4/7 index-pack: remove redundant child fieldJonathan Tan, Oct 17, 2019
  24. Josh SteadmonFeb 28, 2020
  25. 5/7 index-pack: calculate {ref,ofs}_{first,last} earlyJonathan Tan, Oct 17, 2019
  26. 6/7 index-pack: make resolve_delta() assume base dataJonathan Tan, Oct 17, 2019
  27. 7/7 index-pack: make quantum of work smallerJonathan Tan, Oct 17, 2019
  28. Josh SteadmonFeb 28, 2020
  29. Jonathan TanMar 10, 2020
  30. Josh SteadmonFeb 28, 2020
  31. Jonathan TanMar 10, 2020

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.