-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
butex_wake_all support nosignal flag #1751
Conversation
src/bthread/butex.cpp
Outdated
@@ -284,15 +286,19 @@ int butex_wake(void* arg, bool nosched) { | |||
if (!nosched) { | |||
TaskGroup::exchange(&g, bbw->tid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exchange是不是也要传nosignal参数进去
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exchange是希望调度的,所以应该是默认signal的,此外exchange也没有nosignal的参数
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exchange的时候会挂起原来的bthread,这里nosignal的含义是是否立即调度原来的bthread,可以给exchange加个参数。就像bthread_start_urgent也可以传nosignal。
a1f5745
to
7307477
Compare
如果在TaskGroup::exchange的参数变成 TaskGroup::exchange(TaskGroup** pg, bthread_t next_tid, bool nosched, bool nosignal) 把nosched的逻辑放到exchange里面,整个代码逻辑能更简单些。但是exchange的本意就是要切换协程,不知道这样是否合理。 |
exchange本意是切换协程,加上nosched参数不太合理。但是nosignal参数是有意义的。 |
972e867
to
625af37
Compare
已经按照你的建议修改了,这样代码清晰很多 |
625af37
to
f480fad
Compare
nosched参数是不是可以去掉了,如果nosignal是true,就不要调用exchange,而是调用ready_to_run |
你的意思是只需要支持nosched=true && nosignal=true 和 nosched=false && nosignal=false这两种场景是吗? |
嗯,这个需求最初的意思其实是让当前协程不被切换出去,尽量把一些事情处理完了,再统一去调度其他的协程。我再发出一版,辛苦你再Review一下。 |
f6066f6
to
7c214f3
Compare
7c214f3
to
0b1dfc2
Compare
0b1dfc2
to
9779586
Compare
9779586
to
6a91255
Compare
* rm ParseHostname and restore http_message.cpp * reduce ParseUrl() for Init() * update en/http_client.mp * Update circuit_breaker.md * Update overview.md * community: update lorin's oncall report from 08/23/2021 * redesign InitSingle * update docs * Update oncall.md Add caojin's weekly oncall report * add cases.md * add ut add ut * Update oncall.md add link to helei's oncall report * Add use case of Baidu * Improve client doc * Improve client en doc * Improve error_code doc * Improve error_code en doc * Improve server doc * Improve server en doc * Improve cpu_profiler doc * Improve status doc * Improve status en doc * Improve bthread_id doc * EndPoint support ipv4 and unix domain socket * Add EndPoint test for ipv4 and unix domain socket * Support ipv6 and unix domain socket for brpc * Support ipv6 and uds for example echo_c++ * Add doc for IPV6 and Unix domain socket * Add test for consistent_hashing LB with IPV6 and UDS * Update cases.md * Create cases.md * Fix noflush compile fail with glog * Fix typo * Update sampler.cpp fix typo * community: update oncall.md * Fix LA selection runs too long * wr/wrr policy degradation * only support http not http2 * doc(circuit_breaker): add ema wiki link * Update cases.md * Update cases.md * update oncall report * community: add release doc * Update release_cn.md * release 1.0.0 * Update http2_rpc_protocol.cpp grpc add H2 SETTINGS extension,remove this WARNING log。 * Update http2_rpc_protocol.cpp * Add flag `pb_single_repeated_to_array' Add an option to allow serialize/deserialize to/from a json array. * Fix a test case on json to pb * Add test case for `pb_single_repeated_to_array' * Fix a typo of compress type * Update client doc about channel destruction * Fix typo * fix小typo found when following the instruction * update gnp edit command options * when http header parse error, send 400 response * Exclude mesalink/openssl/ssl.h when find openssl Resolve apache#1622 * change varable name * fix status * add release check related content * Update releasecheck.md * update docs * Update images in docs to remove hostname and ip * Add brpc logo Supply a vector graphic logo of brpc(svg) * Update gifs in docs to remove hostname and ip * Update rpc_press doc to remove specific hostname * Replace baidu internal wiki address * minor, fix typo in Stream::OnReceived * Update load_balancer.cpp * added brpc in iqiyi * added case in iqiyi * minor, fix typo in execution_queue.md * Update cpu profiler doc * fix: rpc_view defer_close_second flag typo * update oncall report * doc: add use case * docs(circuit_breaker): fix word error * Add rpc_replay BUILD file * Improvement: brpc support higher version of protobuf * fix(input_messenger) client side retry policy client retry parse message when baidu_std fall to streaming_rpc * Update oncall.md * Create newcommitter.md * add http_host gflag for rpc_replay * update doc for rpc_replay * Support parse proto-text format http request body * make msg more clear * Update oncall.md * change fatal to error * add unittest for proto-text content-type * add protobuf_text content-type ut * docs: fix typo * Fix work_stealing_queue_unittest for ARM. * Fix LatencyRecorder qps not accurate * Fix unstable RecorderTest case * Fix unstable UT link error * Fix unstable UT link error * Add `;` for consistency to origin code. * Typo Fix: Change Resourse to resource * fix(input_messenger) update preferred index fix comments * Update flat_map_unittest.cpp insert test case * [Compile] avoid compile error after gcc11 with --std=c++20 * flat_map: fix code annotation * Update newcommitter.md * Update Thrift download url to avoid pr build failed thrift download url `https://downloads.apache.org/thrift/0.11.0/thrift-0.11.0.tar.gz` has moved to `https://archive.apache.org/dist/thrift/0.11.0/thrift-0.11.0.tar.gz` * ByteSize() is deprecated, use ByteSizeLong() instead * Fix compiler fail after merge apache#1560 and apache#1460 * Fix merge conflicts * Adjust parameter name to be more obvious * Add docs for option `pb_single_repeated_to_array' * Release 1.1.0 * Update newcommitter.md * Update newcommitter.md * Update year in NOTICE * Add list-sigs in release step * add macro * use method instead of macro * change to camel case * Add vote results to incubator vote mail template * doc: Update incubator vote mail template * Update oncall.md * doc: update download link in release doc * [UPDATE] fix c struct compile error solve this error. make it the same as bthread.h * doc: Update announce step in release doc * Oncall report from Apr 10th to Apr 16th * add redis request empty notice * add redis request empty notice * add redis request empty notice * Add redis auth doc * Add oncall report Apr.17th - Apr.24th 2022 * client.md 文档优化 https:// 后面补一个空格,防止后面的中文被Github网页识别成链接的一部分 * fix auto https check * Update oncall.md * `` * client.md 文档优化 (apache#1755) * client.md 文档优化 https:// 后面补一个空格,防止后面的中文被Github网页识别成链接的一部分 * `` * Update oncall.md * comment fix * Update client.md (apache#1767) * json2pb::JsonToProtoMessage() supports parsing multiple jsons * butex_wake* support nosignal flag, use bthread_flush signal batch (apache#1751) * Fix compile error due to std limits header absent (apache#1764) fix compile error like `incubator-brpc/src/brpc/redis_command.cpp:411:29: error: ‘numeric_limits’ is not a member of ‘std’` * Fix _dl_sym undefined reference * Fix a deadlock happened in ClearAbandonedStreamsImpl path(issues/1778) (apache#1781) * Update newcommitter.md * Update newcommitter.md * Update newcommitter.md * Update newcommitter.md * Update newcommitter.md * Support apple silicon * Elaborate how-to-build steps for MacOS * BugFix: Send WindowUpdate when ClearAbandonedStreams is called (apache#1786) * add try catch for thrift * update catch exception * update exception * update exception * update exception * Update oncall.md * Fix discovery naming service core (apache#1802) * Update weighted_randomized_load_balancer.cpp * Update weighted_round_robin_load_balancer.cpp Co-authored-by: LorinLee <lorinlee1996@gmail.com> Co-authored-by: serverglen <serverglen@gmail.com> Co-authored-by: Tanzhongyi(Jerry Tan) <13718272827@163.com> Co-authored-by: Jiashun Zhu <zhujiashun2010@gmail.com> Co-authored-by: tanzhongyi003 <jerrytan@apache.org> Co-authored-by: jamesge <jge666@gmail.com> Co-authored-by: wangweibing <wangweibing@baidu.com> Co-authored-by: YIXIAO SHI <aieruishi@gmail.com> Co-authored-by: jiangtao <hohojiang@126.com> Co-authored-by: yangshuaijie <yangshuaijie@baidu.com> Co-authored-by: huxiguo <uestc.hugo@gmail.com> Co-authored-by: jiaozilang <qql7041@gmail.com> Co-authored-by: caidj <31362185+cdjingit@users.noreply.github.com> Co-authored-by: cdjingit <642580887@qq.com> Co-authored-by: 李磊 <lilei.rd@bytedance.com> Co-authored-by: Jairo <947600215@qq.com> Co-authored-by: Zhangyi Chen <frozen.zju@gmail.com> Co-authored-by: wxf <xiaofeng.wang@bqvision.com> Co-authored-by: Zhengguo Yang <yangzhgg@gmail.com> Co-authored-by: egolearner <45122959+egolearner@users.noreply.github.com> Co-authored-by: therealnick233 <nickpanmail@gmail.com> Co-authored-by: 焦龙 <jiaolong02@meituan.com> Co-authored-by: zhouwk <zhouwk@zenme.com> Co-authored-by: wwbmmm <wwbmmm@163.com> Co-authored-by: Clement Ma <mahongweichina@gmail.com> Co-authored-by: Jiatao Tao <245915794@qq.com> Co-authored-by: ehds <ehds@qq.com> Co-authored-by: caidaojin <caidaojin@qiyi.com> Co-authored-by: dl239 <dl239@126.com> Co-authored-by: taoxu <taoxu@bilibili.com> Co-authored-by: Shuai Zhang <zhangshuai.ustc@gmail.com> Co-authored-by: HongboLiu <lhbf@qq.com> Co-authored-by: Tudou <gao568321994@outlook.com> Co-authored-by: TousakaRin <lhestz@163.com> Co-authored-by: Yangshen⚡Deng <yangshen.d@bupt.edu.cn> Co-authored-by: mwish <anmmscs_maple@qq.com> Co-authored-by: Xiaofeng Wang <wasphin@gmail.com> Co-authored-by: Franklin Shan <37760924+wolfdan666@users.noreply.github.com> Co-authored-by: lzfhust <lzfhust@126.com> Co-authored-by: devin.zhang <devin.zhang@shopee.com> Co-authored-by: lei.li <lei.li@clickzetta.com> Co-authored-by: 372046933 <372046933@users.noreply.github.com> Co-authored-by: Yang,Liming <liming.yang@139.com> Co-authored-by: GOGOYAO <shunyuyao@126.com> Co-authored-by: helei.sig11 <helei.sig11@bytedance.com>
no_signal 为 true,不调用 exchange,ready_to_run* 会传递 no_signal 参数,被唤醒的 bthread 不就无法被及时调度了吗? |
现在我这里每次 butex_wake 后主动调 bthread_flush 解决了不能及时调度的问题。 |
虽然不够优雅,但能解决问题吧,再加参数的话感觉这个接口也太复杂了。 |
butex_wake*的需求 #1749