Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<filesystem>: Improve symlink_status performance #5071

Merged
merged 9 commits into from
Nov 14, 2024

Conversation

nikola-sh
Copy link
Contributor

@nikola-sh nikola-sh commented Nov 9, 2024

_Get_any_status(__Path, __std_fs_stats_flags::_Attributes | __std_fs_stats_flags::_Reparse_tag) calls to many WinAPI functions for regular files or directories. It calls GetFileAttributesEx + CreateFile + GetFileInformationByHandleEx(FileBasicInfo) but GetFileAttributesEx is enough to get all needed data if it is known that a file is not a reparse point.
This problem affects symlink_status performance.

Benchmark symlink_status results before changes:

---------------------------------------------------------
Benchmark               Time             CPU   Iterations
---------------------------------------------------------
symlink_status      15376 ns        15346 ns        44800

Benchmark symlink_status results after changes:

---------------------------------------------------------
Benchmark               Time             CPU   Iterations
---------------------------------------------------------
symlink_status       2219 ns         2148 ns       320000

@nikola-sh nikola-sh marked this pull request as ready for review November 9, 2024 19:52
@nikola-sh nikola-sh requested a review from a team as a code owner November 9, 2024 19:52
@CaseyCarter CaseyCarter added the performance Must go faster label Nov 9, 2024
@CaseyCarter

This comment was marked as resolved.

This comment was marked as resolved.

@StephanTLavavej StephanTLavavej self-assigned this Nov 10, 2024
@StephanTLavavej StephanTLavavej added the filesystem C++17 filesystem label Nov 10, 2024
@StephanTLavavej
Copy link
Member

Thanks! On my system (5950X, 24H2, Samsung SSD 980 PRO), I observe much less of a performance improvement, but still major: 21126 ns => 10098 ns, for a speedup of 2.1x.

@nikola-sh
Copy link
Contributor Author

Thanks! On my system (5950X, 24H2, Samsung SSD 980 PRO), I observe much less of a performance improvement, but still major: 21126 ns => 10098 ns, for a speedup of 2.1x.

Thank you too!
Yes, performance improvement depends on filesystem minifilter drivers configuration.
For example, for paths on system drive GetFileAttributes works much slower than for paths from other drives.

@StephanTLavavej StephanTLavavej changed the title Improve symlink_status performance <filesystem>: Improve symlink_status performance Nov 12, 2024
@StephanTLavavej StephanTLavavej self-assigned this Nov 14, 2024
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@CaseyCarter CaseyCarter removed their assignment Nov 14, 2024
@StephanTLavavej StephanTLavavej merged commit c18bcea into microsoft:main Nov 14, 2024
39 checks passed
@StephanTLavavej
Copy link
Member

Thanks again, and congratulations on your first microsoft/STL commit! 😻 🎉 💾

This change is expected to ship in VS 2022 17.13 Preview 3.

@nikola-sh nikola-sh deleted the fix_symlink_status branch November 14, 2024 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filesystem C++17 filesystem performance Must go faster
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants