On 06/08/2016 09:35 AM, Per Jessen wrote:
It looks like 15'000 calls of lstat() is more likely the issue. I have not yet determined whether that is a reasonable number or not.
Hmm. Not cheap. And why? Is this because of directories with large number of files and obsessive step-and-repeat. Lstat() or even stat() should not be expensive, except perahps for a badly done copy of the data to user space. However the real cost of a stat() call is that of reading the inode from disk. it may involve multiple hits because of path traversal. If *all* of those 15,000 calls *always" involves traversing from "/" that might make it worse. The critical factors are caching, of the inodes, obviously, and not just of the terminal inodes, but the inodes of the traversal path. There's also the pathname caching which should be able to short-cut some that traversal and make better use of the inode caching. But it gets back to "why"? Certainly a change in coding, a "cd('/$base_directory')" then lstat() of just "$filename" rather than a lstat() of "/$base_directory/$filename" would be a better implementation. But, once again, if there is a directory with 15,000 files and its doing a step-and-repeat to find one, then that bad architecture. Take a look, for example, at how Postfix deals with a two-level management structure. -- A: Yes. > Q: Are you sure? >> A: Because it reverses the logical flow of conversation. >>> Q: Why is top posting frowned upon? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org