hazptr: Batches and tags for managing destruction order.
Summary: Add batches and tags for objects protectable by hazard pointers. Add fine-grained cleanup of tagged objects (lower overhead than calling hazptr_cleanup). Design sketch: - The domain structure contains an untagged list and one or more tagged lists (more than one to reduce contention). - These domain lists support lock-free push and lock-free unlocked pop all. Tagged lists are locked by pop all operations and unlocked by push_unlock operations. Push operations are lock-free even when a list is locked for pop all operations. - Batches are lists of retired objects. - Each object contains the address of a batch (or null). The lowest bit indicates if the batch address is used also as a tag. - hazptr_cleanup_batch_tag(tag) reclaims all objects with that tag without checking hazard pointers. - All objects in a domain tagged list contain tagged objects that hash to the index of the list. - Untagged object are those that are safe to reclaim at shutdown time, i.e., their deleter only reclaims memory without other dependencies. - For example, retired UnboundedQueue segments do not depend on user-defined destructors and their deleters merely reclaim memory using the default deleter, and therefore can be untagged. - On the other hand, the deleters of ConcurrentHashMap buckets and nodes depend on user-defined code and therefore their destruction must be managed explicitly. Therefore they are tagged. - Batches can be used even without tagging. For example retired UnboundedQueue segments are collected in batches because they have link-counting interdependencies and batches help keep related segments together. Reviewed By: davidtgoldblatt Differential Revision: D10147101 fbshipit-source-id: 8820cf46ad8942c7362d91543bfbd9fe07e27b7a
Showing
Please register or sign in to comment