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

[PATCH 0/2] Speed up xdiff_outf, and therefore git blame

From
Brian Downing <bdowning@lavos.net>
Date
Aug 13, 2008, 07:04 UTC
Message-ID
<20080813070401.GA4396@lavos.net>

When using git gui blame on some files in one of my repositories, and noticing some rather depressing performance, I decided to look for some low-hanging fruit to optimize.

I found that a lot of the time is spent in xdiff_outf continually xreallocing and freeing memory for a string. I decided to replace that with a strbuf. Unfortunately this now means that there are resources that need to be freed after using xdiff_outf, so a new interface for doing that needed to be created first.

The performance difference on my repository is not amazing, but quite noticeable. Before:

:; time git blame -M -C -C -p --incremental server.c >/dev/null 101.52user 0.17system 1:41.73elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+39561minor)pagefaults 0swaps

After:

:; time git blame -M -C -C -p --incremental server.c >/dev/null 80.38user 0.30system 1:20.81elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+50979minor)pagefaults 0swaps

Obviously, it should improve other uses of xdiff_outf as well, though I doubt many things hit it as hard as blame does.

 [PATCH 1/2] Make xdiff_outf_{init,release} interface
 [PATCH 2/2] Use strbuf for struct xdiff_emit_state's remainder
 builtin-blame.c   |    4 ++--
 combine-diff.c    |    4 ++--
 diff.c            |   20 ++++++++++----------
 xdiff-interface.c |   44 ++++++++++++++++++++++----------------------
 xdiff-interface.h |    6 ++++--
 5 files changed, 40 insertions(+), 38 deletions(-)
-bcd
Message 1 of 1 in “Speed up xdiff_outf, and therefore git blame”
  1. 0/2 Speed up xdiff_outf, and therefore git blameBrian Downing, Aug 13, 2008

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.