Revised reproduction: https://gist.github.com/nazar-pc/db418aeb3e23d6b6499d1ae9d4211290
Feedback Hub: https://aka.ms/AApjlev
GetFileInformationByHandle followed by read with FILE_FLAG_NO_BUFFERING is extremely slow
I have an app that does pre-allocation of the file on disk using GetFileInformationByHandle to check if file already has correct size (here is the exact code in Rust) and then reads many tiny chunks of the file at random using FILE_FLAG_NO_BUFFERING.
The issue is that reads are ~10x faster before GetFileInformationByHandle
is called than after even if the call didn't result in file size change. This makes zero sense to me. Reopening file withing the same process after calling GetFileInformationByHandle
doesn't help either, only process restart.
Interestingly, GetFileInformationByHandleEx doesn't cause such issues.
I resorted to FILE_FLAG_NO_BUFFERING
after discovering memory usage issues due to buggy caching in Windows.
Am I doing anything wrong or the whole file system layer in Windows is hopelessly broken?
1 answer
Sort by: Most helpful
-
Nazar Mokrynskyi 0 Reputation points
2024-03-15T16:48:28.4133333+00:00