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

Re: [PATCH 2/3] gitweb: Cache $parent_commit info in git_blame()

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 10, 2008, 15:15 UTC
Message-ID
<200812101615.55340.jnareb@gmail.com>
In-Reply-To
<182871.96175.qm@web31804.mail.mud.yahoo.com>
On Wed, 10 Dec 2008, Luben Tuikov wrote:
> --- On Tue, 12/9/08, Jakub Narebski <jnareb@gmail.com> wrote:
Show 6 quoted lines
> > This patch attempts to migitate issue [of performance] a bit by
> > caching $parent_commit info in %metainfo, which makes gitweb to
> > call git-rev-parse only once per unique commit in blame output.
> 
> Have you tested this patch that it gives the same commit chain
> as before it?

The only difference between precious version and this patch is that now, if you calculate sha-1 of $long_rev^, it is stored in $metainfo{$long_rev}{'parent'} and not calculated second time.

But I have checked that (at least for single example file) the blame output is identical for before and after this patch.

> > That is what I have noticed during browsing git_blame()
> > code.
> 
> What?

What I have noticed? I have noticed this inefficiency. Why I was browsing git_blame? To write git_blame_incremental...

See also my reply to Nanako Shiraishi with simple benchmark.
> > We can change it to even more effective implementation
> > (like the ones proposed above in the commit message) later.
> 
> Where?

jn> Unfortunately the implementation in 244a70e used one call for jn> git-rev-parse to find parent revision per line in file, instead of jn> using long lived "git cat-file --batch-check" (which might not existed jn> then), or changing validate_refname to validate_revision and made it jn> accept <rev>^, <rev>^^, <rev>^^^ etc. syntax.

One solution mentioned there is to open bidi pipe (like in Git::Repo in gitweb caching by Lea Wiemann) to "git cat-file --batch-check" (the '--batch-check' option was added to git-cat-file by Adam Roben on Apr 23, 2008 in v1.5.6-rc0~8^2~9), feed it $long_rev^, and parse its output of the form:

  926b07e694599d86cec668475071b32147c95034 commit 637

see manpage for git-cat-file(1). Unfortunately it seems like command_bidi_pipe doesn't work as _I_ expected...

Another solution mentioned there is to change validate_refname to validate_revision when checking script parameters (CGI query or path_info), with validate_revision being something like:

  sub validate_revision {
  	my $rev = shift;
	return validate_refname(strip_rev_suffixes($rev));
  }

or something like that, so we don't need to calculate $long_rev^, but can pass "$long_rev^" as 'hb' parameter ($long_rev can in turn also end in '^').

-- 
Jakub Narebski
Poland
Previous: Luben TuikovNext: Luben Tuikov
Message 17 of 31 in “gitweb: Improve git_blame in preparation for incremental blame”
  1. 0/3 gitweb: Improve git_blame in preparation for incremental blameJakub Narebski, Dec 9, 2008
  2. 1/3 gitweb: Move 'lineno' id from link to row element in git_blameJakub Narebski, Dec 9, 2008
  3. Luben TuikovDec 10, 2008
  4. Petr BaudisDec 17, 2008
  5. 2/3 gitweb: Cache $parent_commit info in git_blame()Jakub Narebski, Dec 9, 2008
  6. Nanako ShiraishiDec 10, 2008
  7. Jakub NarebskiDec 10, 2008
  8. Junio C HamanoDec 10, 2008
  9. 2/3 gitweb: Cache $parent_commit info in git_blame()Jakub Narebski, Dec 11, 2008
  10. Luben TuikovDec 11, 2008
  11. Junio C HamanoDec 11, 2008
  12. Junio C HamanoDec 12, 2008
  13. Jakub NarebskiDec 12, 2008
  14. Petr BaudisDec 17, 2008
  15. Junio C HamanoDec 17, 2008
  16. Luben TuikovDec 10, 2008
  17. Jakub NarebskiDec 10, 2008
  18. Luben TuikovDec 10, 2008
  19. Jakub NarebskiDec 10, 2008
  20. Luben TuikovDec 10, 2008
  21. 3/3 gitweb: A bit of code cleanup in git_blame()Jakub Narebski, Dec 9, 2008
  22. Jakub NarebskiDec 10, 2008
  23. Junio C HamanoDec 10, 2008
  24. Luben TuikovDec 10, 2008
  25. 4/3 gitweb: Incremental blame (proof of concept)Jakub Narebski, Dec 10, 2008
  26. Junio C HamanoDec 11, 2008
  27. Jakub NarebskiDec 11, 2008
  28. Jakub NarebskiDec 11, 2008
  29. Jakub NarebskiDec 11, 2008
  30. gitweb: Incremental blame (proof of concept)Jakub Narebski, Dec 14, 2008
  31. [RFC] gitweb: Incremental blame - suggestions for improvementsJakub Narebski, Dec 14, 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.