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

Re: hosting git on a nfs

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Nov 14, 2008, 05:01 UTC
Message-ID
<alpine.LFD.2.00.0811132044460.3468@nehalem.linux-foundation.org>
In-Reply-To
<885649360811131933webae91w134dce4c5c0ccf89@mail.gmail.com>
On Thu, 13 Nov 2008, James Pickens wrote:
> 
> I wonder if there are other completely different parts of git that could
> benefit from multi threading when the work tree is on nfs?

I'm sure there are. That said, threading things is usually really quite painful. The only reason this preloading was easy to do was that we really had all the data structures laid out beautifully for this, and I had spent a lot of effort earlier on a whole series of "avoid duplicate lstat()" changes, which gave us that whole ce_uptodate() thing, and all normal cases already taking advantage of it, and the "uptodate" bit being percolated along all the paths.

If it hadn't been for that, it would have been much nastier to do.

As it was, there was literally just a simple little extra phase to fill in all teh data structures that we already had set up in parallel.

> I'm thinking specifically of 'git checkout', since while testing this 
> patch I happened to do a 'git pull' that resulted in several thousand 
> new files being created, and the "Checking out files" part took 
> *forever* to run.

Now, the good news is that the actual work-tree part of checking things out is probably pretty amenable to the same kind of parallelization, for largely the same reasons: the whole checking out thing is already done in multiple phases with all error handling done before-hand. So we will have built up all our data structures earlier, and set the CE_UPDATE bit, and then there's just a final "push it all out" phase.

So CE_UPTODATE and CE_UPDATE are really very similar in that sense - except at opposite ends of the pipeline. The CE_UPTODATE bit marks a name entry as matching the filesystem data (and allows all later phases to avoid doing the expensive lstat()s), while the CE_UPDATE (and CE_REMOVE) bits allow us to do all our complex work in-memory without committing it to disk, and then we push it out in one go.

So if you want to multi-thread checkout, you literally need to just thread the last for-loop in unpack-trees.c:check_updates() (the CE_UPDATE loop that does "checkout_entry()" over the whole index).

> And FWIW, I timed 50 iterations of 'git diff', and the average runtime
> dropped from 11.7s to 2.8s after this patch.  A nice improvement.

Very impressive. That said, I suspect you get a "superlinear" improvement because once it gets faster, the kernel cache also works better, since you can do more loops without having the NFS attributes time out.

Whether that kind of effect happens much in actual practice is debatable, although it's quite possible that it will work the same way in some scripting schenarios.

			Linus
Previous: James PickensNext: Michael J Gruber
Message 20 of 44 in “hosting git on a nfs”
  1. Thomas KochNov 12, 2008
  2. Julian PhillipsNov 12, 2008
  3. Brandon CaseyNov 12, 2008
  4. David BrownNov 12, 2008
  5. Linus TorvaldsNov 12, 2008
  6. J. Bruce FieldsNov 13, 2008
  7. James PickensNov 13, 2008
  8. Linus TorvaldsNov 13, 2008
  9. Linus TorvaldsNov 13, 2008
  10. James PickensNov 13, 2008
  11. Linus TorvaldsNov 13, 2008
  12. Julian PhillipsNov 13, 2008
  13. Linus TorvaldsNov 13, 2008
  14. Julian PhillipsNov 14, 2008
  15. Brandon CaseyNov 14, 2008
  16. Linus TorvaldsNov 14, 2008
  17. Pieter de BieNov 14, 2008
  18. Linus TorvaldsNov 14, 2008
  19. James PickensNov 14, 2008
  20. Linus TorvaldsNov 14, 2008
  21. Michael J GruberNov 14, 2008
  22. Kyle MoffettNov 14, 2008
  23. Brandon CaseyNov 14, 2008
  24. Linus TorvaldsNov 14, 2008
  25. Junio C HamanoNov 14, 2008
  26. Linus TorvaldsNov 14, 2008
  27. Makefile: introduce NO_PTHREADSJunio C Hamano, Nov 15, 2008
  28. Linus TorvaldsNov 15, 2008
  29. Mike RalphsonNov 17, 2008
  30. Junio C HamanoNov 17, 2008
  31. Johannes SixtNov 17, 2008
  32. Mike RalphsonNov 17, 2008
  33. Johannes SixtNov 17, 2008
  34. Johannes SixtDec 1, 2008
  35. dhruvaDec 1, 2008
  36. Mike RalphsonDec 1, 2008
  37. Makefile: introduce NO_PTHREADSMike Ralphson, Dec 1, 2008
  38. Makefile: introduce NO_PTHREADSMike Ralphson, Dec 1, 2008
  39. Johannes SixtDec 2, 2008
  40. Junio C HamanoDec 3, 2008
  41. Junio C HamanoNov 17, 2008
  42. Linus TorvaldsNov 17, 2008
  43. Fix index preloading for racy dirty caseLinus Torvalds, Nov 17, 2008
  44. Junio C HamanoNov 17, 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.