Windows 中 CreateFile 的默认缓冲区大小是多少?
当在没有标志 FILE_FLAG_NO_BUFFERING 的情况下调用 CreateFile 函数时, 操作系统内部缓冲区的大小是多少?
如果我的缓冲区大小大于 Windows 的内部缓冲区,我可以吗 完全用完磁盘的吞吐量?
When CreateFile Function is called without the flag FILE_FLAG_NO_BUFFERING,
what is the size of the inner buffer of operating system?
If my buffer size is larger than the inner buffer of Windows, can I
fully use up the throughput of disk?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它可能因 Windows 版本而异,并且取决于可用 RAM 的量。 您应该简单地使用适合您的应用程序的缓冲区大小进行读取和写入,而不是依赖于任何特定的内容。
It likely varies from windows version to windows version, as well as depending on the amount of free RAM. Rather than relying on anything specific, you should simply do reads and writes with buffer sizes that work well for your application.
这取决于您有多少内存以及机器的配置方式。 服务器通常配置为特权系统缓存。 您可以通过更改以下注册表项来更改该
设置 SetSystemFileCacheSize 函数 可以用于改变缓存大小。 然而,据我了解,设置工作集大小更多的是对操作系统的提示,而不是硬性限制。
关于你的第二个问题,我不太清楚你的意思。 我不知道缓冲区的大小将如何影响吞吐量,但我确信如果我错了,有人会纠正我。
It depends how much RAM you have, and how the machine is configured. Servers are usually configured to privilege system cache. You could change that by altering the following registry key
The SetSystemFileCacheSize function can be used to alter the cache size. However, from what I understand, setting the working set size is more of a hint to the operating system than a hard limit.
In regards to your second question, I'm not exactly sure what you mean. I don't see how the size of your buffer will affect throughput, but I'm sure someone will correct me if I'm wrong.
如果您使用无缓冲,那么除了您提供给读/写的缓冲区之外,实际上没有用于 I/O 的缓冲区。 (压缩文件除外,这是一个不同的蜡球。)
在这种情况下,系统缓存将被忽略,这就是您需要的原因(请参阅 MSDN) 要小心 I/O 的对齐和大小。
If you're using no-buffering, there really isn't a buffer for the I/O other than the one you gave to read/write. (This is excepting compressed files, which is a different ball of wax.)
The system cache is ignored in this case, which is why you're required (see MSDN) to be careful with alignment and the size of your I/O.