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

Re: git-testadd: Execute a command with only the staged changes in Git applied

From
Øyvind A. Holm <sunny@sunbase.org>
Date
Jul 28, 2016, 23:17 UTC
Message-ID
<CAA787rnugsnAqK6iH_UZMQRhdpnjJ6NN0x8aaVn7e9GAE88=jQ@mail.gmail.com>
In-Reply-To
<xmqqzip1pew5.fsf@gitster.mtv.corp.google.com>
On 29 July 2016 at 00:38, Junio C Hamano <gitster@pobox.com> wrote:
Show 30 quoted lines
> Øyvind A. Holm <sunny@sunbase.org> writes:
> > Jakub Narębski <jnareb@gmail.com> wrote:
> > > I wonder if using `git worktree` instead of `git clone` (well,
> > > local clone uses hardlinks, so it is not that costly as it looks
> > > like) would be a better solution.
> >
> > That's an interesting idea. Have to test it out. This is the result
> > from the current master in linux.git:
> >
> > With clone:
> > ...
> > With worktree:
> > ...
> >
> > Both tests were run with cold cache ("echo 3
> > >/proc/sys/vm/drop_caches" as root). It seems as there's no
> > >difference, and that git clone is as fast as it can get without
> > >breaking physical laws. And we probably shouldn't do that. :)
>
> I expect that writing the 55k+ files in the working tree would
> dominate the cost.  Local clone would make some hardlinks in .git
> (including ones in .git/object/*) but the cost of that would not be
> too high as long as the repository is well packed; "git worktree"
> would reduce that part of the cost from "git clone", but both incur
> the cost of "checkout", i.e. actually populating the new working tree.
>
> Does the test directory even need to look anything like Git?  In other
> words, would it suffice if it resembled the result of running "git
> archive | tar xf -"?  I suspect that it would not make much
> difference, either, for the same reason, though ;-).
Using git archive saved 1.6 seconds:
  $ mkdir testdir; git archive HEAD | (cd testdir && time tar x)
  real    0m8.881s
  user    0m0.440s
  sys     0m2.740s
  $

But when .git is missing in the subdir, git apply doesn't work. Can't think of any way to get that to work without involving patch(1) and friends, and then the binary diffs goes out of the window.

But I'm quite satisfied with 10.4 seconds with cold diskcache and >55K files. Very impressive, actually.

- Øyvind
Previous: Øyvind A. Holm
Message 5 of 5 in “git-testadd: Execute a command with only the staged changes in Git applied”
  1. Øyvind A. HolmJul 28, 2016
  2. Øyvind A. HolmJul 28, 2016
  3. Jakub NarębskiJul 28, 2016
  4. Øyvind A. HolmJul 28, 2016
  5. Øyvind A. HolmJul 28, 2016

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.