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

Re: q: faster way to integrate/merge lots of topic branches?

From
IMIngo Molnar <mingo@elte.hu>
Date
Jul 23, 2008, 13:49 UTC
Message-ID
<20080723134926.GA12888@elte.hu>
In-Reply-To
<20080723131736.GA9100@elte.hu>
* Ingo Molnar <mingo@elte.hu> wrote:
> So i guess it's better to just create a separate 
> .git/refs/merge-cache/ hierarchy with timestamps of last merged 
> branches and their head sha1 ... but maybe i'm banging on open doors?

here's the git-fastmerge script i've whipped up in 10 minutes. It does the trick nicely for me:

first run:
  real    0m53.228s
  user    0m41.134s
  sys     0m11.405s
second run:
  real    0m2.751s
  user    0m1.280s
  sys     0m1.491s
or a 20x speedup. Yummie! :-)

It properly notices when i commit to a topic branch, and it maintains a proper matrix of <A> <- <B> merge timestamps. It even embedds the sha1's in the timestamp path so it should be quite complete. It should work fine across resets, re-merges, etc. too i think. It should work well with renamed branches as well i think. (although i dont do that all that often)

In fact even if i delete the whole .git/mergecache/ hierarchy and run a 'cold' merge, it's much faster:

  real    0m32.129s
  user    0m24.456s
  sys     0m7.603s

Because many of the branches have the same sha1 so it's already half-optimized even on the first run.

Much of the remaining 2.7 seconds overhead comes from the git-log runs to retrieve the sha1s, so i guess it could all be made even faster.

Now this scheme assumes that there's a sane underlying filesystem that can take these long pathnames and which has good timestamps (which i have, so it's not a worry for me).

Hm?
	Ingo

-----------------{ git-fastmerge }---------------------> #!/bin/bash

usage () {
  echo 'usage: git-fastmerge <refspec>..'
  exit -1
}
[ $# = 0 ] && usage
BRANCH=$1
MERGECACHE=.git/mergecache
[ ! -d $MERGECACHE ] && { mkdir $MERGECACHE || usage; }

HEAD_SHA1=$(git-log -1 --pretty=format:"%H") BRANCH_SHA1=$(git-log -1 --pretty=format:"%H" $BRANCH)

CACHE=$MERGECACHE/$HEAD_SHA1/$BRANCH_SHA1
[ -f "$CACHE" -a "$CACHE" -nt .git/refs/heads/$BRANCH_SHA1 ] && {
  echo "merge-cache hit on HEAD <= $1"
  exit 0
}
git-merge $1 && {
  mkdir -p $(dirname $CACHE)
  touch $CACHE
}
Previous: Ingo MolnarNext: Jay Soffian
Message 3 of 32 in “q: faster way to integrate/merge lots of topic branches?”
  1. Ingo MolnarJul 23, 2008
  2. Ingo MolnarJul 23, 2008
  3. Ingo MolnarJul 23, 2008
  4. Jay SoffianJul 23, 2008
  5. Ingo MolnarJul 23, 2008
  6. Ingo MolnarJul 23, 2008
  7. Andreas EricssonJul 23, 2008
  8. Ingo MolnarJul 23, 2008
  9. Miklos VajnaJul 23, 2008
  10. Sergey VlasovJul 23, 2008
  11. Ingo MolnarJul 23, 2008
  12. Ingo MolnarJul 23, 2008
  13. SZEDER GáborJul 23, 2008
  14. Ingo MolnarJul 23, 2008
  15. Junio C HamanoJul 23, 2008
  16. 1/2 builtin-branch.c: remove unused code in append_ref() callback functionJunio C Hamano, Jul 23, 2008
  17. builtin-branch.c: optimize --merged and --no-mergedJunio C Hamano, Jul 23, 2008
  18. Lars HjemliJul 24, 2008
  19. Nanako ShiraishiJul 24, 2008
  20. Lars HjemliJul 24, 2008
  21. Ingo MolnarJul 24, 2008
  22. Linus TorvaldsJul 23, 2008
  23. Linus TorvaldsJul 23, 2008
  24. Junio C HamanoJul 23, 2008
  25. Ingo MolnarJul 24, 2008
  26. Junio C HamanoJul 25, 2008
  27. Björn SteinbrinkJul 23, 2008
  28. Santi BéjarJul 23, 2008
  29. Linus TorvaldsJul 23, 2008
  30. Pierre HabouzitJul 23, 2008
  31. Pierre HabouzitJul 23, 2008
  32. Pierre HabouzitJul 23, 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.