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

Re: [PATCH 4/3] Avoid using 'lstat()' to figure out directories

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

Possibly related (same subject, not in this thread)

On Fri, 10 Jul 2009, Paolo Bonzini wrote:
I'm not much worried about accessing foo-0001, foo-0002, foo-0003 while 
looking for foo/a (that would be O(number of files in a directory), 
which is bearable), but risking to go down a huge subtree is not very 
nice.
That sounds rather unlikely, and the thing is, even if it were to happen, 
it really wouldn't be that slow. Our data structures are pretty efficient, 
and it wouldn't be _that_ slow to traverse them.

That said, I don't love that loop. It would be better to do that whole 
cache_name_pos() call with the '/' simply appended to the path, and then 
we'd do the binary search directly to the first entry.

Of course, since 'path' is a 'const char *', we'd need to either do a 
silly copy, or we'd need to change a whole lot of the code to make it 
clear that we can actually add a slash to the end (which we can: I think 
it's already always going to be an array that we _will_ add a slash to in 
case it turns out to be a directory).

So there's definitely room for improvement there. I just think that the 
improvement isn't the patch you suggest.

			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