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

Re: [PATCH] ref-filter: disable save_commit_buffer while traversing

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 11, 2022, 21:27 UTC
Message-ID
<xmqqilo3mjbp.fsf@gitster.g>
In-Reply-To
<Ysw4JtoHW1vWmqhz@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 6 quoted lines
>   - Note that all of this assumes you don't have a commit-graph file. if
>     you do, then the heap usage is even lower, and the runtime is 10x
>     faster. So in that sense this is not urgent, as there's a much
>     better solution. But since it's such an obvious and easy win for
>     fallback cases (including commits which aren't yet in the graph
>     file), there's no reason not to.
Sounds sensible.
Show 45 quoted lines
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> Just pulling this out of the discussion in:
>
>   https://lore.kernel.org/git/YswuaPx6Mk7YkIim@coredump.intra.peff.net/
>
> as it's an easy win.
>
> I doubt that anyone even cares about restoring the value of
> save_commit_buffer. So this _could_ be a one-liner turning it off,
> rather than doing the save/restore dance. I was mostly erring on the
> conservative side, but maybe fewer lines of code is a worthwhile thing.
>
>  ref-filter.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/ref-filter.c b/ref-filter.c
> index d3c90e5dbe..bdf39fa761 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -2405,13 +2405,17 @@ static void reach_filter(struct ref_array *array,
>  int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int type)
>  {
>  	struct ref_filter_cbdata ref_cbdata;
> +	int save_commit_buffer_orig;
>  	int ret = 0;
>  
>  	ref_cbdata.array = array;
>  	ref_cbdata.filter = filter;
>  
>  	filter->kind = type & FILTER_REFS_KIND_MASK;
>  
> +	save_commit_buffer_orig = save_commit_buffer;
> +	save_commit_buffer = 0;
> +
>  	init_contains_cache(&ref_cbdata.contains_cache);
>  	init_contains_cache(&ref_cbdata.no_contains_cache);
>  
> @@ -2444,6 +2448,7 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
>  	reach_filter(array, filter->reachable_from, INCLUDE_REACHED);
>  	reach_filter(array, filter->unreachable_from, EXCLUDE_REACHED);
>  
> +	save_commit_buffer = save_commit_buffer_orig;
>  	return ret;
>  }
Previous: Jeff King
Message 4 of 4 in “ref-filter: disable save_commit_buffer while traversing”
  1. ref-filter: disable save_commit_buffer while traversingJeff King, Jul 11, 2022
  2. Ævar Arnfjörð BjarmasonJul 11, 2022
  3. Jeff KingJul 11, 2022
  4. Junio C HamanoJul 11, 2022

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.