p.magalhaes
p.magalhaes

Reputation: 8354

optimization - reading file from disk with Windows API

I am using the Windows API to work with files. My performance is very good. I read file in chunks but i don't know the optimum size of it. I know it should be a multiple of the cluster size of the disk.

Does the disk has a cache? IF i use a chunk larger than the cache my performance should worst? Am I correct?

thanks!

Upvotes: 2

Views: 172

Answers (1)

Itaypk
Itaypk

Reputation: 1133

Yes, Windows is providing a cache layer when working with files. See official MS documentation. I'm not sure about the exact cache size and possible tradeoffs, good chance the cache size depends on the system's available memory size and maybe other factors.

Another good way to improve performance is to use the asynchronous I/O API. It's harder to write and maintain, but improves your performance. See official example.

Upvotes: 1

Related Questions