-
Notifications
You must be signed in to change notification settings - Fork 180
Shard jar map #919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Shard jar map #919
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
2de993f
to
5d6cafe
Compare
CodSpeed Performance ReportMerging #919 will degrade performances by 4.37%Comparing Summary
Benchmarks breakdown
|
The benchmarks are probably misleading here because they're single threaded. |
5d6cafe
to
dd31360
Compare
dd31360
to
b21f69f
Compare
Did you try changing the ty benchmark by removing the thread pool override in the setup here: This should be a very good benchmark to show the impact of this change Edit 1I made the change real quick and here are the results: mainsingle threaded
multi threaded
PRsingle threaded
multi threaded
The first run is still significantly faster (which is expected), but it's at least no longer the case that multithreaded is slower than single-threaded! I'm not quite sure why I can't observe the 10x slowdown anymore on main. Edit 2Wait, it now makes sense. I need to reduce the sample size to 1 or divan takes the median from two runs; Mainsingle
multi
This PRsingle
multi
So this is pretty good. It reduces the 5-6x slow down to a 1.5-2x slow down. I'm still not sure if that's good enough for us to enable multi threading in benchmarks because it probably adds too much overhead but this is a huge improvement in production when running with more than one db. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! It would be nice to reduce this even further (e.g. could we use a lock free map that's optimized for reads?) but this is a great first step.
Replaces the jar map with a
DashMap
. This depends on ibraheemdev/boxcar#35, which allows us to claim multiple sequential ingredient indices without holding a global lock.This should also help with #918, because the slow path for accessing an uncached ingredient now goes through a sharded
DashMap
instead of a singleMutex
, but I don't think we have benchmarks that use multiple databases yet (I'll add some). The ideal fix for that issue might also be to extend theIngredientCache
, but this should at least help. We could also look into using papaya here (or more extreme,ArcSwap
?), because the jar map is almost purely read-heavy after the table is initially filled.