Hacker News new | ask | show | jobs
by shepardrtc 595 days ago
How do you determine the number of shards to use?
2 comments

I use a multiple of `std::thread::available_paralellism()`. Tbh I borrowed the strategy from dashmap, but I tested others and this seemed to work quite well. Considering making that configurable in the future so that it can be specialized for different use-cases or used in single-threaded but cooperatively scheduled contexts.
(std::thread::available_parallelism().map_or(1, usize::from) * 4).next_power_of_two()