• Marko Mäkelä's avatar
    MDEV-26467: Avoid futile spin loops · 277ba134
    Marko Mäkelä authored
    Typically, index_lock and fil_space_t::latch will be held for a longer
    time than the spin loop in latch acquisition would be waiting for.
    Let us avoid spin loops for those as well as dict_sys.latch, which
    could be held in exclusive mode for a longer time (while loading
    metadata into the buffer pool and the dictionary cache).
    
    Performance testing on a dual Intel Xeon E5-2630 v4 (2 NUMA nodes)
    suggests that the buffer pool page latch (block_lock) benefits from a
    spin loop in both read-only and read-write workloads where the working
    set is slightly larger than the buffer pool. Presumably, most contention
    would occur on leaf page latches. Contention on upper level pages in
    the buffer pool should intuitively last longer.
    
    We introduce srw_spin_lock and srw_spin_mutex to allow users of
    srw_lock or srw_mutex to opt in for the spin loop.
    On Microsoft Windows, a spin loop variant was and will not be available;
    srw_mutex and srw_lock will simply wrap SRWLOCK.
    That is, on Microsoft Windows, the parameters innodb_sync_spin_loops
    and innodb_spin_wait_delay will only affect block_lock.
    277ba134
btr0sea.cc 59.7 KB