• Maysam Yabandeh's avatar
    WritePrepared: reduce prepared_mutex_ overhead (#5420) · c292dc85
    Maysam Yabandeh authored
    The patch reduces the contention over prepared_mutex_ using these techniques:
    1) Move ::RemovePrepared() to be called from the commit callback when we have two write queues.
    2) Use two separate mutex for PreparedHeap, one prepared_mutex_ needed for ::RemovePrepared, and one ::push_pop_mutex() needed for ::AddPrepared(). Given that we call ::AddPrepared only from the first write queue and ::RemovePrepared mostly from the 2nd, this will result into each the two write queues not competing with each other over a single mutex. ::RemovePrepared might occasionally need to acquire ::push_pop_mutex() if ::erase() ends up with calling ::pop()
    3) Acquire ::push_pop_mutex() on the first callback of the write queue and release it on the last.
    Pull Request resolved: https://github.com/facebook/rocksdb/pull/5420
    Differential Revision: D15741985
    Pulled By: maysamyabandeh
    fbshipit-source-id: 84ce8016007e88bb6e10da5760ba1f0d26347735