• Marko Mäkelä's avatar
    MDEV-24167: Use lightweight srw_lock for btr_search_latch · c561f9e6
    Marko Mäkelä authored
    Many InnoDB rw-locks unnecessarily depend on the complex
    InnoDB rw_lock_t implementation that support the SX lock mode
    as well as recursive acquisition of X or SX locks.
    One of them is the bunch of adaptive hash index search latches,
    instrumented as btr_search_latch in PERFORMANCE_SCHEMA.
    Let us introduce a simpler lock for those in order to
    reduce overhead.
    
    srw_lock: A simple read-write lock that does not support recursion.
    On Microsoft Windows, this wraps SRWLOCK, only adding
    runtime overhead if PERFORMANCE_SCHEMA is enabled.
    On Linux (all architectures), this is implemented with
    std::atomic<uint32_t> and the futex system call.
    On other platforms, we will wrap mysql_rwlock_t with
    zero runtime overhead.
    
    The PERFORMANCE_SCHEMA instrumentation differs
    from InnoDB rw_lock_t in that we will only invoke
    PSI_RWLOCK_CALL(start_rwlock_wrwait) or
    PSI_RWLOCK_CALL(start_rwlock_rdwait)
    if there is an actual conflict.
    c561f9e6
btr0sea.cc 59.2 KB