Performance degrades when accessing large files with FILE_FLAG_RANDOM_ACCESS


Operating system performance may degrade when one or more processes access multiple large files using the CreateFile() API and the FILE_FLAG_RANDOM_ACCESS flag. The performance degradation is due to the system cache consuming available memory (visible in the performance counter Memory\Cache Bytes).


The FILE_FLAG_RANDOM_ACCESS flag is a hint to the Cache Manager that the file will be opened for random I/O. Random I/O means there is no predictable pattern to the I/O that will take place. This flag disables intelligent read-aheads and prevents automatic unmapping of views after pages are read to minimize mapping/unmapping when the process revisits that part of the file. This keeps previously read views in the Cache Manager working set. However, if the cumulative size of the accessed files exceeds physical memory, keeping so many views in the Cache Manager working set may be detrimental to overall operating system performance because it can consume a large amount of physical RAM.


Remove the FILE_FLAG_RANDOM_ACCESS flag when the application opens the file(s) with CreateFile. This will allows the views to be unmapped and moved to the standby list after page reads are completed. This will require involvement from the software developer.