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

Re: [PATCH v3 1/4] alloc: introduce parsed_commits_count

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 12, 2020, 22:00 UTC
Message-ID
<xmqqpna40ws8.fsf@gitster.c.googlers.com>
In-Reply-To
<xmqqtuzg11zv.fsf@gitster.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 24 quoted lines
> Abhishek Kumar <abhishekkumar8222@gmail.com> writes:
>
>>  static unsigned int alloc_commit_index(struct repository *r)
>>  {
>> -	return r->parsed_objects->commit_count++;
>> +	static unsigned int parsed_commits_count = 0;
>> +	r->parsed_objects->commit_count++;
>> +	return parsed_commits_count++;
>>  }
>
> Hmph, ugly.  
>
> The need for this hack, which butchers the function that explicitly
> takes a repository as its parameter so that parsed commits can be
> counted per repository to not count commits per repository, makes
> the whole thing smell fishy.
>
> There shouldn't be a reason why a commit in the superproject and
> another commit in the submodule need to be in the same commit graph
> in the first place.
>
> Instead of breaking the function like this, the right "fix" may be
> to make the commit slab per repository, because the commit index are
> taken from the separate namespace per repository.

Given a commit object (i.e. "struct commit *"), currently there is no way to tell from which repository it came from. So from that point of view, we cannot identify which commit slab to use, unless we add a back-pointer that says from which repository each commit object came from, but that makes the commit object even heavier.

Back when 14ba97f8 (alloc: allow arbitrary repositories for alloc functions, 2018-05-15) made the count per repository (which you are reverting with this patch), there must have been a reason why it did so. We know that commit slab code wants you to count globally and that is why you wrote this patch, but don't other parts of the code expect and rely on the commits being counted per repository? In other words, with this change, who are you breaking to help the commit slab code?

Cc'ing SZEDER who also have touched this and made the function static early last year.

Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 14 in “Move generation, graph_pos to a slab”
  1. 0/4 Move generation, graph_pos to a slabAbhishek Kumar, Jun 12, 2020
  2. 1/4 alloc: introduce parsed_commits_countAbhishek Kumar, Jun 12, 2020
  3. Junio C HamanoJun 12, 2020
  4. Junio C HamanoJun 12, 2020
  5. Junio C HamanoJun 12, 2020
  6. Junio C HamanoJun 12, 2020
  7. Abhishek KumarJun 13, 2020
  8. Jakub NarębskiJun 12, 2020
  9. 2/4 commit-graph: introduce commit_graph_data_slabAbhishek Kumar, Jun 12, 2020
  10. SZEDER GáborJun 13, 2020
  11. Abhishek KumarJun 17, 2020
  12. 3/4 commit: move members graph_pos, generation to a slabAbhishek Kumar, Jun 12, 2020
  13. 4/4 commit-graph: minimize commit_graph_data_slab accessAbhishek Kumar, Jun 12, 2020
  14. Jakub NarębskiJun 12, 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.