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

Re: [PATCH v2] log: grep author/committer using mailmap

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 27, 2012, 18:45 UTC
Message-ID
<7v1uebmizx.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1356622318-19523-1-git-send-email-apelisse@gmail.com>
Antoine Pelisse <apelisse@gmail.com> writes:
Show 12 quoted lines
> Currently you can use mailmap to display log authors and committers
> but you can't use the mailmap to find commits with mapped values.
>
> This commit allows you to run:
>
>     git log --use-mailmap --author mapped_name_or_email
>     git log --use-mailmap --committer mapped_name_or_email
>
> Of course it only works if the --use-mailmap option is used.
>
> Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
> ---
Thanks.  I'll queue this on top.
-- >8 --
Subject: [PATCH] log --use-mailmap: optimize for cases without --author/--committer search

When we taught the commit_match() mechanism to pay attention to the new --use-mailmap option, we started to unconditionally copy the commit object to a temporary buffer, just in case we need the author and committer lines updated via the mailmap mechanism.

It turns out that this has a rather unpleasant performance implications. In the linux kernel repository, running

  $ git log --author='Junio C Hamano' --pretty=short >/dev/null

under /usr/bin/time, with and without --use-mailmap (the .mailmap file is 118 entries long, the particular author does not appear in it), cost (with warm cache):

  [without --use-mailmap]
  5.34user 0.25system 0:05.60elapsed 100%CPU (0avgtext+0avgdata 2004832maxresident)k
  0inputs+0outputs (0major+137600minor)pagefaults 0swaps
  [with --use-mailmap]
  6.87user 0.24system 0:07.11elapsed 99%CPU (0avgtext+0avgdata 2006352maxresident)k
  0inputs+0outputs (0major+137696minor)pagefaults 0swaps

which is with about 29% overhead. The command is doing extra work, so the extra cost may be justified.

But it is inexcusable to pay the cost when we do not need author/committer match. In the same repository,

  $ git log --grep='fix menuconfig on debian lenny' --pretty=short >/dev/null
shows very similar numbers as the above:
  [without --use-mailmap]
  5.30user 0.24system 0:05.55elapsed 99%CPU (0avgtext+0avgdata 2004896maxresident)k
  0inputs+0outputs (0major+137604minor)pagefaults 0swaps
  [with --use-mailmap]
  6.82user 0.26system 0:07.07elapsed 100%CPU (0avgtext+0avgdata 2006352maxresident)k
  0inputs+0outputs (0major+137697minor)pagefaults 0swaps

The latter case is an unnecessary performance regression. We may want to _show_ the result with mailmap applied, but we do not have to copy and rewrite the author/committer of all commits we try to match if we do not query for these fields.

Trivially optimize this performace regression by limiting the rewrites for only when we are matching with author/committer fields.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 revision.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/revision.c b/revision.c
index fa16b9d..56b72f7 100644
--- a/revision.c
+++ b/revision.c
@@ -2283,7 +2283,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
 	if (buf.len)
 		strbuf_addstr(&buf, commit->buffer);
 
-	if (opt->mailmap) {
+	if (opt->grep_filter.header_list && opt->mailmap) {
 		if (!buf.len)
 			strbuf_addstr(&buf, commit->buffer);
 
-- 
1.8.1.rc3.221.g8d09d94
Previous: Antoine PelisseNext: Junio C Hamano
Message 7 of 15 in “Mailmap in log improvements”
  1. 0/2 Mailmap in log improvementsAntoine Pelisse, Dec 22, 2012
  2. 1/2 log: grep author/committer using mailmapAntoine Pelisse, Dec 22, 2012
  3. Junio C HamanoDec 26, 2012
  4. Antoine PelisseDec 26, 2012
  5. Junio C HamanoDec 26, 2012
  6. log: grep author/committer using mailmapAntoine Pelisse, Dec 27, 2012
  7. Junio C HamanoDec 27, 2012
  8. Junio C HamanoDec 27, 2012
  9. Antoine PelisseDec 28, 2012
  10. Junio C HamanoDec 28, 2012
  11. Antoine PelisseDec 28, 2012
  12. 2/2 log: add log.mailmap configuration optionAntoine Pelisse, Dec 22, 2012
  13. Junio C HamanoDec 23, 2012
  14. Junio C HamanoDec 26, 2012
  15. Antoine PelisseDec 26, 2012

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.