Windows CreateFile slow when opening a large numbe

2019-09-19 18:16发布

I am using a directory that has about 3000 files. I am aware of the NTFS threads that have talked about CreateFile being slow for reading files in the quantity of 100,000s or millions. My number isn't nearly that high yet it still takes about 4-7 ms for CreateFile to complete which adds up when I'm opening 3000 files. So my problem is similar to the post below. On some machines it is lightning fast when I invoke CreateFile and then on other ones it is this 4-7 ms speed. I've tried Fat32 filesystem and NTFS with no luck, it is slow on both. Same with Win7 and Win10, slow on both. The only commonality that I have noticed is that the machines where it is slow seem to be on machines that are using SATA/RAID controllers and fast on machines that have standard SATA. All of the machines are using SSD drives.

As a note: I am doing the same thing as the thread below as part of my experiment. I have a simple program that invokes CreateFile and then CloseHandle. Does nothing else and is very slow on some machines(4-7ms CreateFile) and fast on others as described above. The following thread is a very similar question but there was never a good answer for it.

Why is windows so slow in opening files first time and is there a faster way

Thank you

dgraves

1条回答
贪生不怕死
2楼-- · 2019-09-19 18:35

So I was mistaken. I didn't have any third party anti-virus software installed, however Microsoft Security Essentials was still installed. This is definitely the problem and it makes sense that CreateFile would be slower when MSE is running. So if you have MSE or Windows Defender running this will slow down CreateFile significantly.

查看更多
登录 后发表回答