Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

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

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:47:02


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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help