You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reduce contention in large [de]allocation fast path #466
Large allocation currently requires holding both arena->lock and arena->extents_mtx. We can push extents_mtx down to individual size classes so that different size classes can be operated on concurrently. On top of that we can completely avoid arena->lock in the fast path if some stats fields are refactored such that the arena only stores per size class stats, and the ctl refresh code synthesizes the top level stats via aggregation.
Other issues:
The arena->large list will need to be broken into per size class lists.
The arena->extents_dirty ring will need to either become lock-free, or per size class (with e.g. per extent timestamps or serial numbers that allow approximate order reconstruction).
We have now reduced large [de]allocation contention substantially, to the point that going any further would risk increased common-case overhead due acquiring/releasing more locks per operation. The same applies to lockless data structures -- the heaps and LRUs are currently very fast (and protected by a single mutex lock/unlock per operation), but lockless replacements would require many atomic instructions per operation. Current benchmarking evidence (both microbenchmarks and real-world) suggests that further optimization may not be warranted. For the time being we are done with this issue. If further scalability issues crop up, we can open more specific issues.
Just as a note from my own experience with lock-free code: lock-free code is almost always slower on any individual path. But it wins on parallelism, because while lock-free isn't always wait-free, it usually is. And so while each thread does more work individually, no thread gets stuck waiting for a thread that holds a lock but has been descheduled by the kernel.
Note that e201e24 was a follow-on to this issue, necessary to reduce TLB shootdown overhead. Additionally, cdce93e further streamlines fast-path large allocation by converting pairing heap operational complexity to the equivalent of LIFO operations.
Activity
jasone commentedon Feb 17, 2017
We have now reduced large [de]allocation contention substantially, to the point that going any further would risk increased common-case overhead due acquiring/releasing more locks per operation. The same applies to lockless data structures -- the heaps and LRUs are currently very fast (and protected by a single mutex lock/unlock per operation), but lockless replacements would require many atomic instructions per operation. Current benchmarking evidence (both microbenchmarks and real-world) suggests that further optimization may not be warranted. For the time being we are done with this issue. If further scalability issues crop up, we can open more specific issues.
IndolentPangolin commentedon Feb 17, 2017
Just as a note from my own experience with lock-free code: lock-free code is almost always slower on any individual path. But it wins on parallelism, because while lock-free isn't always wait-free, it usually is. And so while each thread does more work individually, no thread gets stuck waiting for a thread that holds a lock but has been descheduled by the kernel.
jasone commentedon Mar 8, 2017
Note that e201e24 was a follow-on to this issue, necessary to reduce TLB shootdown overhead. Additionally, cdce93e further streamlines fast-path large allocation by converting pairing heap operational complexity to the equivalent of LIFO operations.