Use RWLock for shrink map as map should be small, and dashmap is empty checks are expensive#7007
Conversation
…y checks are expensive
370a499 to
7f08999
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7007 +/- ##
=========================================
- Coverage 83.2% 83.2% -0.1%
=========================================
Files 853 853
Lines 375393 375427 +34
=========================================
+ Hits 312520 312523 +3
- Misses 62873 62904 +31 🚀 New features to boost your workflow:
|
|
Also, can you mark the PR Ready for Review and add @HaoranYi as a reviewer, please? |
Ha, sorry. I had requested it for review and then reverted it to draft and removed reviewers as I wanted to gather more data |
HaoranYi
left a comment
There was a problem hiding this comment.
lgtm.
Do you have timing for shrink? The original dashmap will allow concurrent access between clean and shrink as long as they are looking up in different shards. Rwlock will prevent all concurrent access. It is likely that shrink won't be affected since it is not a big map. Just want to double check to make sure.




Problem
Empty checks on dashmaps are expensive
Summary of Changes
Since shrink map is relatively small, replace with RwLock
Grabbed a quick check of clean timings:

The line of interest is the blue line. Others are just reference lines. There are three different versions running on the blue line:
3 3rd restart is with the RwLock and removing all the asserts
1 & 3 seem noticeably better. I don't see a real difference between 1 and 3, so I am proposing the RwLock to keep the asserts.
There are many other paths effected by the empty check, but they have more noise than the clean flow.
Fixes #