• Maged Michael's avatar
    hazard pointers: Optimize allocation of hazard pointers from domain · 0e92d3c2
    Maged Michael authored
    Summary:
    Optimize the management of available hazard pointers in the domain that are not in thread caches, by adding a linked list of available hazard pointers with a lock bit packed with the pointer to the head of the list. Pop operations are done in two atomic steps: (1) set lock bit, (2) pop hazard pointers and clear lock bit. Push operations are done in one atomic step, but can proceed only when the lock bit is clear.
    
    Microbenchmark results (in a process with 10K+ hazard pointers) show reduction in the latency of constructing destroying two 9-hazard-pointer-arrays that involve one TC hit and one TC miss/overflow from hundreds of microseconds to tens of nanoseconds.
    
    Before:
    ```
    1/1000 TC hit + miss & overflow                   550 ns    502 ns    468 ns
    ```
    
    After:
    ```
    TC hit + miss & overflow                           49 ns     48 ns     48 ns
    ```
    
    Reviewed By: yfeldblum
    
    Differential Revision: D31102053
    
    fbshipit-source-id: ae923bf3b05676e7572cca35179531e947846300
    0e92d3c2
HazptrTest.cpp 43.7 KB