Skip to content

Reduce contention in large [de]allocation fast path #466

Closed

Description

@jasone

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).

See #360 for context.

Activity

  1. added this to the 5.0.0 milestone on Oct 4, 2016
  2. jasone commented on Feb 17, 2017

    @jasone
    MemberAuthor

    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.

  3. IndolentPangolin commented on Feb 17, 2017

    @IndolentPangolin

    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.

  4. jasone commented on Mar 8, 2017

    @jasone
    MemberAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions