免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2007 | 回复: 6
打印 上一主题 下一主题

[内核入门] 多次唤醒等待队列,对性能影大么? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-08-31 20:08 |只看该作者 |倒序浏览
模拟场景:线程A睡在等待队列上,等待被唤醒,其主要负责处理所有的请求。
              线程(1~10)不停的提交请求,提交成功后,唤醒等待队列。(假设提交的很频繁)。

问题:1。正常理解是提交一个请求,就应该去唤醒等待队列。但是如果大家都添加一个请求后,就去唤醒队列。对系统性能或者负载影响大么?
         2。若新建立一个线程,专门去负责唤醒队列,唤醒条件为:如果队列中请求超过某个阈值,则立即唤醒队列;或队列不为空,且超过100ms,也去唤醒队列?


PS:大家有什么好建议?

论坛徽章:
1
双鱼座
日期:2013-08-28 13:47:26
2 [报告]
发表于 2013-09-01 10:40 |只看该作者
本帖最后由 firkraag 于 2013-09-01 17:38 编辑

1. If thread A is busying on processing the pending requests(means it is running), it could not sleep on the wait queue and there is nothing affecting it with the calling of wakeups. Otherwise, it will be wakeup by the call. The penalties will be the calls of wakeup when thread A is running. Many a little makes a mickle, perhaps it will do some native effects on the performance.

2. If you want to reorder the requests quite like the block device i/o request queues do, it can be used for reference.

BTW, the wait queue and request queue are not the same one.

论坛徽章:
0
3 [报告]
发表于 2013-09-01 11:32 |只看该作者
是的,如果 thread A已经是running状态,再次唤醒是没什么大影响的。
但是不确定 thread A的状态,如果有大量请求,则希望 thread A尽量少的进入睡眠状态。

论坛徽章:
1
双鱼座
日期:2013-08-28 13:47:26
4 [报告]
发表于 2013-09-01 18:16 |只看该作者
Maybe can use one flag in request queue to express whether the thread A is running.

If you mean the request queue sync problem between the process thread(eg. thread A) and submit threads, you can use two request queues: one for pending requests, while one for dispatching requests. When the dispatching queue is empty, let the thread A swaps the two pointers of the two queues and continue to process.

No need to create another wakeup thread, just compare the pending requests number in the submit threads and use timer to deal with time-out.

论坛徽章:
0
5 [报告]
发表于 2013-09-01 20:52 |只看该作者
恩,我可以试试。3Q

论坛徽章:
6
金牛座
日期:2013-10-08 10:19:10技术图书徽章
日期:2013-10-14 16:24:09CU十二周年纪念徽章
日期:2013-10-24 15:41:34狮子座
日期:2013-11-24 19:26:19未羊
日期:2014-01-23 15:50:002015年亚洲杯之阿联酋
日期:2015-05-09 14:36:15
6 [报告]
发表于 2013-09-02 08:21 |只看该作者
回复 1# 鬼鬼一哈
这个要看具体的业务场景了。本身内核的wake_up操作是不会影响性能的。

   

论坛徽章:
0
7 [报告]
发表于 2013-09-02 21:26 |只看该作者
回复 6# 瀚海书香
恩,关键是添加请求到队列中和唤醒队列后,处理请求,会互相抢占锁。。。3Q

   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP