仅在 I/O 负载较低时运行线程
我有一个执行 I/O 操作的后台线程(保持索引最新)。 但除此之外,还有多个客户端访问服务器的硬盘,我希望这些访问尽可能快。 所以我想,如果索引线程只在 I/O 负载较低时运行,那就太好了。
有办法解决这个问题吗?
我也愿意接受其他建议。
I have a background thread that performs I/O operations (keeping an index up to date). But in addition to that several clients access the server's hard disk and I want these accesses as fast as possible. So I thought, it would be nice, if the indexing thread is only running when the I/O load is low.
Is there a way to figure this out?
I'm open for alternative suggestions as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用性能计数器获取磁盘的 I/O 活动。 一旦达到阈值的下限,就允许线程运行。 在决定停止阈值的高端时,不要忘记考虑您将添加的 I/O 负载。
Use Performance Counters to get the I/O activity of the disks. Once it gets to the low-end of your threshold, allow your threads to run. Don't forget to take into account your own I/O load you'll be adding when deciding what your high-end is for the stopping threshold.
将线程优先级设置为空闲应该就足够了。
编辑
您说得对,线程的优先级不会影响 IO 优先级。
看看我/ O Windows Vista 中的优先级详细说明。
Setting your threads priority to idle should be sufficient.
Edit
You are right about the fact that the thread's priority does not impact the IO priority.
Take a look at I/O Prioritization in Windows Vista for a detailed explanation.