How to make the OS to do prefetch in the case of 4KB block sized random reads?

Rahul Raj 0 Reputation points
2024-09-25T11:56:05.8033333+00:00

I have a C++ application which does random read on a local DB in Windows 10 HDD system. For a particular operation , after seeking to a random offset , then a sequential read of about 5 to 15kb is done and this continues until an entire file is read (100 MB). The current block size used 512 bytes on analyzing with Windows Performance Analyzer ,it is seen that OS is able to prefetch almost the whole data.

When switching, to 4KB block size , anticipating increase in IO performance, it is seen that performance degradation is happening and OS is not able to prefetch any data. Wanted to understand , what causes the OS to not prefetch data in 4KB Block size. And, if possible how to make OS to prefetch data?

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Wesley Li 11,255 Reputation points
    2024-09-25T16:39:19.3866667+00:00

    Hello

    It sounds like you're experiencing an interesting issue with prefetching in Windows 10 when switching from a 512-byte block size to a 4KB block size.

    According to an article on TechPowerUp, changing the logical sector size to 4KB can sometimes lead to performance degradation due to compatibility issues and the way the operating system handles data prefetching. The article explains that while 4KB block sizes can theoretically improve performance by reducing the overhead of managing smaller blocks, it can also lead to inefficiencies if the OS and applications are not optimized for this block size.

    To address the issue, you might consider the following approaches:

    Optimize the Application: Ensure that your application is optimized for 4KB block sizes. This might involve adjusting the way data is read and processed to align with the larger block size.

    Adjust OS Settings: Investigate if there are any OS-level settings or registry tweaks that can improve prefetching for larger block sizes. This might involve adjusting the prefetcher settings or other memory management parameters.

    Use a Hybrid Approach: If possible, consider using a hybrid approach where critical data is read using smaller block sizes while less critical data uses larger block sizes. This can help balance the performance benefits of both block sizes.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.