https://bugs.llvm.org/show_bug.cgi?id=47307

            Bug ID: 47307
           Summary: filesystem directory_iterator calls stat on every file
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: l...@alex.lanin.de
                CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com

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:
    https://github.com/ccache/ccache/blob/8b595b04ce6/src/Util.cpp#L1308
    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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to