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

Re: diffcore-rename performance mode

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 18, 2007, 08:49 UTC
Message-ID
<7vsl5cwe6p.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20070918082321.GA9883@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 11 quoted lines
> There seems to be a serious performance problem in diffcore-rename.
> There is infrastructure to cache the "cnt_data" member of each filespec,
> but it never gets used because we immediately free the filespec data
> after use. Oops.
>
> With this patch:
> ...
> My 20-minute diff becomes a 2-minute diff. The downside is that the
> memory usage is much increased (for obvious reasons, it should increase
> by the dataset size, since we are keeping pointers to the data around --
> in my case, around 1G extra).

Yes, these early freeing of filespec_data() were introducd later specifically to address the memory usage issue.

> However, keeping around _just_ the
> cnt_data caused only about 100M of extra memory consumption (and gave
> the same performance boost).
That would be an interesting and relatively low-hanging optimization.
> The spanhash data structure is a bit confusing. At first, it looked like
> we were doing a linear search for a matching hash, but it's not quite,
> since we seem to start at some magic spot based on the hashval we're
> looking up.

I think it was just a hash table with linear overflow (if your spot is occupied by somebody else, you look for the next available vacant spot -- works only if you do not ever delete items from the table) but sorry, I do not recall the rationale for picking that data structure. I vaguely recall I did some measurement between that and the usual "an array that is indexed with a hash value that holds heads of linked lists" and pointer chasing appeared quite cache-unfriendly to the point that it actually degraded performance, but did not try very hard to optimize it.

Previous: Jeff KingNext: Jeff King
Message 2 of 13 in “diffcore-rename performance mode”
  1. Jeff KingSep 18, 2007
  2. Junio C HamanoSep 18, 2007
  3. Jeff KingSep 18, 2007
  4. Junio C HamanoSep 18, 2007
  5. Jeff KingSep 18, 2007
  6. Junio C HamanoSep 18, 2007
  7. Johannes SchindelinSep 18, 2007
  8. Jeff KingSep 25, 2007
  9. Jeff KingSep 25, 2007
  10. Andreas EricssonSep 25, 2007
  11. David KastrupSep 25, 2007
  12. Jeff KingSep 25, 2007
  13. Linus TorvaldsSep 18, 2007

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.