LindaSummer commented on code in PR #2461:
URL: https://github.com/apache/kvrocks/pull/2461#discussion_r1703265043
##########
src/server/worker.h:
##########
@@ -88,9 +91,10 @@ class Worker : EventCallbackBase<Worker>,
EvconnlistenerBase<Worker> {
UniqueEvent timer_;
std::thread::id tid_;
std::vector<evconnlistener *> listen_events_;
- std::mutex conns_mu_;
- std::map<int, redis::Connection *> conns_;
- std::map<int, redis::Connection *> monitor_conns_;
+ mutable std::mutex conns_mu_; // refer to
https://github.com/oneapi-src/oneTBB/issues/183, traverse and erase should
Review Comment:
Hi @mapleFU ,
Thanks for your suggestions!
I have been inspired by your reference of [tbb source
file](https://github.com/oneapi-src/oneTBB/blob/v2021.13.0/include/oneapi/tbb/concurrent_hash_map.h#L1033-L1051).
I switched from the cpp style for loop to `tbb::parallel_for` and
`tbb_parallel_reduce`.
The `range()` method is commented as `Parallel algorithm support`.
It works now and the mutex has been removed. 😊
I read the source code of `tbb::parallel_recude` and
`tbb::concurrent_hashmap::range()` and it seems that the partitioner will help
[split the
range](https://github.com/oneapi-src/oneTBB/blob/v2021.13.0/include/oneapi/tbb/partitioner.h#L273-L291)
before execution.
Best Regards,
Edward
--
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]