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

Re: [PATCH 7/3] Make index preloading check the whole path to the file

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jul 11, 2009, 03:04 UTC
Message-ID
<alpine.LFD.2.01.0907101957200.3552@localhost.localdomain>
In-Reply-To
<7veisorkux.fsf@alter.siamese.dyndns.org>
On Fri, 10 Jul 2009, Junio C Hamano wrote:
> 
> I actually was hoping to hear "Didn't you notice that this is the first
> function run by the pthread and its stack is zeroed by thread creation" or
> something clever like that ;-)

It's probably true that it is often zero in practice. I certainly saw no problems in my testing, even though I do have preloading on (partly for testing, partly because it actually helps a bit on my machine).

I also suspect that the way the whole 'cache_def' thing works, even if it's initialized with random crud, you'll probably never notice. There are all those safety rules that check that 'cache->track_flags' has to match the new value etc in order for the cache to be used. And even when it is used, it has no pointers in it, it has that static array and the lengths.

So I don't think you really even need to have the "it was zeroed by accident" explanation. It's probably as simple as "even if it is totally uninitialized, that will basically never trigger anything odd in practice".

Not to mention that the whole new index preloading addition was just a new safety feature that we didn't even use to have before - and one that only impacted an _optimization_ that didn't change semantics. So in the end: even in the really unlikely situation that the cache would have triggered, and returned an incorrect return value, the worst that would have happened would be that the preloading wasn't quite as efficient.

End result: you did well by noticing the lack of initializers, but I _really_ don't think it could probably ever possibly have mattered in practice.

			Linus
Previous: Junio C HamanoNext: Kjetil Barvik
Message 26 of 39 in “Too many 'stat' calls by git-status on Windows”
  1. Dmitry PotapovJul 7, 2009
  2. Ramsay JonesJul 8, 2009
  3. Linus TorvaldsJul 9, 2009
  4. Linus TorvaldsJul 9, 2009
  5. 1/3 Add 'fill_directory()' helper function for directory traversalLinus Torvalds, Jul 9, 2009
  6. 2/3 Simplify read_directory[_recursive]() argumentsLinus Torvalds, Jul 9, 2009
  7. 3/3 Avoid doing extra 'lstat()'s for d_type if we have an up-to-date cache entryLinus Torvalds, Jul 9, 2009
  8. Junio C HamanoJul 9, 2009
  9. Linus TorvaldsJul 9, 2009
  10. Junio C HamanoJul 9, 2009
  11. Linus TorvaldsJul 9, 2009
  12. Junio C HamanoJul 9, 2009
  13. Linus TorvaldsJul 9, 2009
  14. Linus TorvaldsJul 9, 2009
  15. Junio C HamanoJul 9, 2009
  16. Linus TorvaldsJul 9, 2009
  17. 4/3 Avoid using 'lstat()' to figure out directoriesLinus Torvalds, Jul 9, 2009
  18. 5/3 Prepare symlink caching for thread-safetyLinus Torvalds, Jul 9, 2009
  19. 6/3 Export thread-safe version of 'has_symlink_leading_path()'Linus Torvalds, Jul 9, 2009
  20. 7/3 Make index preloading check the whole path to the fileLinus Torvalds, Jul 9, 2009
  21. Linus TorvaldsJul 9, 2009
  22. Junio C HamanoJul 10, 2009
  23. Linus TorvaldsJul 10, 2009
  24. Linus TorvaldsJul 10, 2009
  25. Junio C HamanoJul 11, 2009
  26. Linus TorvaldsJul 11, 2009
  27. Kjetil BarvikJul 12, 2009
  28. Junio C HamanoJul 12, 2009
  29. Paolo BonziniJul 9, 2009
  30. Linus TorvaldsJul 9, 2009
  31. Linus TorvaldsJul 9, 2009
  32. Linus TorvaldsJul 10, 2009
  33. Junio C HamanoJul 9, 2009
  34. Dmitry PotapovJul 9, 2009
  35. Eric BlakeJul 9, 2009
  36. Dmitry PotapovJul 9, 2009
  37. Dmitry PotapovJul 10, 2009
  38. Dmitry PotapovJul 9, 2009
  39. Dmitry PotapovJul 9, 2009

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.