feat(EventsCBGExecutor): Added worker queue - #3277
jmachowinski wants to merge 2 commits into
Conversation
The worker queue should improve the usage of cold vs hot threads, by reusing threads that have been recently used. There are also some improvements around not waking up threads if they can't get work anyway. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
|
Pulls: #3277 |
ABI Compliance Check❌ Verdict: incompatible
✅
|
|
@fujitatomoya this is clearly a false positive in the abi checker. It fails to realize that everything that changed is part of a pimple pattern and not public ABI. |
|
Also why are we running it for rolling ? |
|
@jmachowinski - I think it's so we can know if a change to rolling will successfully backport to older distros. but yeah this should probably also take into account PIMPL and whether an affected class is part of the public API or not |
|
Hu what is going on with these benchmarks, they don't match my expectations and tests at all.... |
|
ah wait I think this was with irobot benchmark before all of our recent changes. Won't be able to rerun them for a few days |
@jmachowinski thanks for flagging this! i need to considerr pimpl pattern probably the policy requirement by the project... honestly i missed this case... good eye! (CC: @skyegalaxy thanks for the explanation.) for now, you can ignore those abi compliance result, this has been still tested in rolling branch to detect the missing cases like exactly this one. edit: tracking issue for ROS 2 abi checker, fujitatomoya/ros2-abi-action#15 |
|
Yeah, I wouldn't treat the ABI results as absolute yet. I think they are the direction that we need to move in, but it may take a few iterations to get it exactly right. Because of that, I agree with @skyegalaxy that running on rolling can at least give us a good idea of backport risk (and help inform new rules). |
fujitatomoya
left a comment
There was a problem hiding this comment.
overall, lgtm with a couple of comments.
| release_worker_once = true; | ||
| } | ||
| work_ready_conditional.notify_one(); | ||
| worker->unblock(); |
There was a problem hiding this comment.
this could be called on a destroyed mutex/condition_variable and leads to UB? the popper seems to hold the raw pointer outside any lock between pop_blocked_worker_thread() and unblock()?
There was a problem hiding this comment.
The worker struct is initialized on the stack of the worker thread. If it is in the queue it is blocked and can not start to run. Therefore the lifetime of the struct should be guaranteed as the thread can not terminate.
| std::unique_lock lk(mutex); | ||
| wakeup = true; | ||
| } | ||
| condition_variable.notify_one(); |
There was a problem hiding this comment.
notify_one() after unlocking a destructible Worker here? because the waiter's exit condition becomes visible the moment the lock is released, the waiter can wake, observe wakeup, return, exit run(), and destroy the Worker while the notifier is still inside notify_one() on the now-destroyed CV?
There was a problem hiding this comment.
I introduced a new unblocking function for the shutdown race.
Signed-off-by: Janosch Machowinski <j.machowinski@cellumation.com>
I get through the bank better performance results in my benchmark with this branch |












Description
The worker queue should improve the usage of cold vs hot threads, by reusing threads that have been recently used.
There are also some improvements around not waking up threads if they can't get work anyway.
Is this user-facing behavior change?
No
Did you use Generative AI?
Yes for code reviews and checks
Additional Information