JimChengLin commented on PR #2907: URL: https://github.com/apache/brpc/pull/2907#issuecomment-3068085551
> > 在这个 MR 之前,一个线程可能就访问一个 parking lot,在这个 MR 可能需要访问陌生的 parking lot? > > 是的,一个ParkingLot已经futex_wait,挂起了。但是此时signal里有可能没有同步到_waiter_num大于0,所以直接返回,去访问其他ParkingLot了。这个PR之前是直接futex_wake就成功了。我理解是这个差异可能会导致futex竞争变大了。暂时没想到其他场景了。 > > > 但我很怀疑把 waiter num 和 signal 合并后,会有什么收益,这样对条件的竞争不是更严重吗? > > 应该没啥性能收益吧,单纯考虑正确性而已,使用signal/wait都用CAS或者fetch_add保证可见性,有个问题就是wait也加入竞争了。 > > 但是目前不知道要咋实现。 > > > 把 parking lot 默认 shard 数目调高试试呢?这样对单个 parking lot 竞争更小,waiter num 和 signal 的不同步概率就更低。 > > 试过了,调高ParkingLot数目不会降低signal/wait的qps,都相比这个PR之前高。 那这个可能是 corner case,这种永远能都唤醒 + waiter num 偶尔是 0 的 case,这个 MR 可能确实是负优化。绝大多数情况,特别是永远都唤醒不了的 case,这个 MR 优化是比较大的。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
