<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - filesystem directory_iterator calls stat on every file"
href="https://bugs.llvm.org/show_bug.cgi?id=47307">47307</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>filesystem directory_iterator calls stat on every file
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm@alex.lanin.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>On my machine directory_iterator executes stat on every single file. For others
it does not. My best guess is that the behavior is related to WSL2 as that's
the major difference I have to the other machine where tested.
Unfortunately I do not know how to investigate further. If anyone wants to look
at this and does not have WSL I could certainly provide more info if directed
how to do that.
Code:
for (auto& p : std::filesystem::recursive_directory_iterator(path)) {}
Measurement:
strace -e trace=%file -r ./run 2> syscalls.txt
Comparison vs:
<a href="https://github.com/ccache/ccache/blob/8b595b04ce6/src/Util.cpp#L1308">https://github.com/ccache/ccache/blob/8b595b04ce6/src/Util.cpp#L1308</a>
Note: _DIRENT_HAVE_D_TYPE is defined
Time measurement listing llvm files via google benchmark:
opendir ~105ms
std::filesystem::directory_iterator ~350ms
std::filesystem::recursive_directory_iterator ~350ms
Compiled via:
CC=gcc CXX=g++ cmake ../llvm/ -GNinja
-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;libcxx;libcxxabi;compiler-rt'
-DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86"
-DLLVM_APPEND_VC_REV=Off -DLLVM_CCACHE_BUILD=On
Version:
51a82828fb291fc8f77 (23. Aug 2020)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>