如何在 Windows 中选择文件 I/O 缓冲区大小来读取文件?
在调查通过 WAN 读取文件时应用程序性能缓慢的情况时,我注意到在 Windows 资源管理器中复制该文件的速度要快得多。
对 Process Monitor 的一些进一步调查揭示了原因:我的应用程序使用 C 运行时的默认 BUFSIZE 512,而 Windows 资源管理器以某种方式确定它应该以 61440 字节块读取文件(这显然是 SMB 或 Windows 支持的最大大小) ' SMB 的实施)。因此,Windows 资源管理器必须减少很多往返次数,并且运行速度要快得多。
大多数缓冲区大小建议都在 4k-16k 范围内,但对于 WAN 环境,通过最大化缓冲区大小来最小化往返行程是有意义的。 Windows 资源管理器如何确定要使用的缓冲区大小?
While investigating some slow performance in my application while reading a file over a WAN, I noticed that copying that file in Windows Explorer was significantly faster.
Some further investigation with Process Monitor revealed the cause: my application was using the C runtime's default BUFSIZE of 512, while Windows Explorer had somehow determined that it should read the file in 61440 byte blocks (which is apparently the maximum supported by either SMB or Windows' implementation of SMB). As a result, Windows Explorer had to make a LOT fewer round trips and ran a lot faster.
Most recommendations for buffer size are somewhere in the 4k-16k range, but for a WAN environment, minimizing round trips by maximizing the buffer size makes sense. How does Windows Explorer determine what buffer size to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我本以为小于网络 MTU 的东西可能会更好
I would have thought that something less than the network MTU might be good