Skip to content
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

Optionally support parking_lot within global allocators. #305

Closed
wants to merge 3 commits into from

Commits on Dec 8, 2021

  1. Optionally support parking_lot within global allocators.

    This adds a feature to support using parking_lot locks in
    `#[global_allocator]` implementations. The main hazard is parking_lot calling
    into the global allocator, and then the global allocator calling back into
    parking_lot, at a point where parking_lot is not prepared to be re-entered on
    the same thread.
    
    There are currently two places where this comes up:
    
     - When a new thread is created, parking_lot needs to allocate space in its
       hashtable for the new thread. It uses the global allocator to allocate this
       space, and if the global allocator uses parking lot, it doesn't work because
       the hashtable is not ready for the new thread yet.
    
     - If the new hashtable is allocated while bucket locks are held, and the
       global allocator attempts to acquire a parking lot lock, it deadlocks
       because all the buckets are locked.
    
    This defines a new "global_allocator_compat" feature. When defined:
    
    The hashtable growing code checks whether it's being reentered, and does no
    growth in that case.
    
    And, `create_hashtable` will allocate the new `HashTable` before locking all
    the bucket locks, to avoid deadlock if allocating the `HashTable` attempts to
    take a lock.
    
    And, a new function, `init`, is defined, for allocating the initial
    hashtable. This must be done before performing any syncronization.
    sunfishcode committed Dec 8, 2021
    Configuration menu
    Copy the full SHA
    e7e94cd View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2021

  1. Configuration menu
    Copy the full SHA
    0afa01d View commit details
    Browse the repository at this point in the history

Commits on Dec 10, 2021

  1. Configuration menu
    Copy the full SHA
    b9e0b54 View commit details
    Browse the repository at this point in the history