Conversation
Codecov Report
Additional details and impacted files
|
jonhoo
left a comment
There was a problem hiding this comment.
Nice, thanks for pushing this forward!
I took a look at the code for fast-counter, and had a couple of thoughts:
- I think
THREAD_IDcan be aCell<usize>instead of anUnsafeCell. Should let you get rid of theunsafeblock you have in there. - On
nightlyyou can useThreadId::as_u64rather than keepingTHREAD_IDyourself. - It's not entirely clear to me why you have stable and nightly separated? The use of
#[thread_local]doesn't feel like it's very important, and in terms of performance the difference seems fairly minor.
Thanks for the feedback, all great points, I'll try address these soon. The reason for the night / stable just happened as an effect of me starting with the nightly first, and originally the performance difference was greater. I left it was an |
|
Hey @jonhoo been looking into this and a few thoughts and findings:
Thanks again for reviewing this |
|
Sorry for the super slow reply!
Looking at the
That's super weird! The code for
Nice!
Ah, yes, that's a great point, and a totally valid reason for using an
Thanks for digging so deep! |
|
Actually, on second thought, in a concurrent setting with lazily updated counters, it's entirely possible that the sum of the counters ends up being negative for some shorter period of time. So I think we should actually leave the return value as an |
src/map.rs
Outdated
| let _saw_bin_length = match resize_hint { | ||
| Some(hint) => hint, | ||
| None => return | ||
| }; |
There was a problem hiding this comment.
nit: I'd probably make this an if let Some
|
Looks like there are some CI failures now? |
|
I've been following along somewhat closely and happy to see that you guys made good progress. 🎉 If either of you ever need assistance (with anything really) you can always @ me :) (although I'm fairly certain you both got this in the bag). Well done Jack & Jon! |
Saw these, I'll take a look at resolving them when I get a chance! Thanks for running the workflow |
c92dbf2 to
b4e58f8
Compare
Update to track the size using the fast-counter crate which scales better to a higher core count.
b4e58f8 to
7ac8031
Compare
|
I completely forgot about this PR sorry @jonhoo. I've rebased the PR and addressed your comment. |
|
FWIW I am using this simple approach in papaya. The counters are accessed using |
That's awesome! Just curious what performance difference did you see using this compared to a regular isize in papaya? |
|
I don't have the numbers handy but it was a noticeable improvement for |
This is picking up from the great work from @jimvdl in this PR: #101
I've added the crate here: https://github.com/JackThomson2/fast-counter which is using a basic sharded concurrent counter which is identified using a thread_local. It seems at worse case it's slightly slower but with more cores it starts to pull ahead.
These are the results using the conc-bench repo on my 16 core machine:
This change is