Skip to content

Commit

Permalink
Optimize project scanning on Windows
Browse files Browse the repository at this point in the history
We were using FindFirstFileW instead of FindFirstFileExW, which provides
two optimization opportunities for folder scanning:

- Specifying FindExInfoBasic avoids computing short file names
  (cAlternativeFileName), which we never use
- Specifying FIND_FIRST_EX_LARGE_FETCH increases the internal buffer
  sizes used for reading file entries

When folder hierarchy is cached (hot), the first optimization improves
scan performance by ~10%. When folder hierarchy is read from disk (cold),
the second optimization improves scan performance by ~25%. The numbers
are measured on Windows 11 / Samsung 970 EVO / x64 on Linux kernel
source tree (65k files)
  • Loading branch information
zeux committed Jun 11, 2024
1 parent 88e27b1 commit d4100ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/fileutil_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static bool traverseDirectoryRec(const wchar_t* path, const char* relpath, const
std::wstring query = path + std::wstring(L"/*");

WIN32_FIND_DATAW data;
HANDLE h = FindFirstFileW(query.c_str(), &data);
HANDLE h = FindFirstFileExW(query.c_str(), FindExInfoBasic, &data, FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH);

if (h == INVALID_HANDLE_VALUE)
return false;
Expand Down

0 comments on commit d4100ca

Please sign in to comment.