Skip to content
  • Sunny Bains's avatar
    139b0f3f
    Bug 21052754 ADD SHOW ENGINE INNODB MUTEX FUNCTIONALITY · 139b0f3f
    Sunny Bains authored
    Add the functionality that was removed in WL#6044. However, this is a compelete
    rewrite of SHOW ... MUTEX infrastructure inside InnoDB. The RW-Locks tracking
    however was not changed in any substantial way. Except that some useless debug
    counters were removed and the waits are now enabled/reset/disabled using the
    Monitor infrastructure.
    
    In the old SHOW ... MUTEX For each mutex pointer and rw-lock pointer we were
    doing a search through all the buffer pool chunks to check if the pointer was
    contained within to identify if it was a page mutex/rw-lock or not. For large
    buffer pools this is unacceptable. To avoid these expensive scans, I've added
    a LATCH_ID to identify each mutex and rw-lock. Removed the cfile_name and
    cline from the mutex definition and moved them to a separate lookup table.
    This information is only used when there is a problem and is very rare but
    under normal operation they take up sizeof(void*) + sizeof(uint16_t) space,
    the sizeof(uint16_t) actually occupies 8 bytes due to the alignment. The size
    of the mutex was therefore 72 bytes. It has now been reduced to:
    
    We don't track the create file and line number for the block mutexes. There
    are just too many of them and they are all created in the same file(buf0buf.cc)
    and on the same line number, you can grep the code to figure that out.
    
      gdb) p sizeof(ib_mutex_t)
          $1 = 48
    
    For rw_lock_t, add a is_block_lock flag. This flag is set in buf0buf.cc where
    the block lock is created.
    
    Removed UNIV_SYNC_DEBUG. UNIV_DEBUG will by default do sync order checking.
    Add read-only debug config variable: --innodb-sync-debug (default: true).
    Potential use case is to run the latch ordering checks in the weekly tests
    if the overhead is too much for daily tests.
    
    Added dynamic enable/disable/reset of mutex/rw statistic gathering using
    the existing monitor infrastructure
    
        SET GLOBAL innodb_monitor_enable="latch";
        SET GLOBAL innodb_monitor_reset="latch";
        SET GLOBAL innodb_monitor_disable="latch";
    
    Added additonal information to the SHOW ... MUTEX OUTPUT
    
    mysql> show engine innodb mutex;
    +--------+-------------------------+------------------------------------------+
    | Type   | Name                    | Status                                   |
    +--------+-------------------------+------------------------------------------+
    | InnoDB | TRX_SYS                 | spins=3371806,waits=44790,calls=800875   |
    ...
    | InnoDB | rwlock: log0log.cc:784  | waits=3                                  |
    +--------+-------------------------+------------------------------------------+
    
    The "Name" columns will now display the mutex name and not the filename:line
    format which was very build specific. For RW-LOCKS we will stick with the old
    format.
    
    Fixed several bugs in the SyncDebug checks that were introduced in WL#6044.
    
    Moved the low level OS mutex to a separate class with a separate interface.
    We can't track these because they are implemented outside of InnoDB.
    
    Remove UNIV_DEBUG_FILE_ACCESSES, fold into UNIV_DEBUG
    
    Approved by Jimmy Yang and Bin Su rb#9037
    139b0f3f
    Bug 21052754 ADD SHOW ENGINE INNODB MUTEX FUNCTIONALITY
    Sunny Bains authored
    Add the functionality that was removed in WL#6044. However, this is a compelete
    rewrite of SHOW ... MUTEX infrastructure inside InnoDB. The RW-Locks tracking
    however was not changed in any substantial way. Except that some useless debug
    counters were removed and the waits are now enabled/reset/disabled using the
    Monitor infrastructure.
    
    In the old SHOW ... MUTEX For each mutex pointer and rw-lock pointer we were
    doing a search through all the buffer pool chunks to check if the pointer was
    contained within to identify if it was a page mutex/rw-lock or not. For large
    buffer pools this is unacceptable. To avoid these expensive scans, I've added
    a LATCH_ID to identify each mutex and rw-lock. Removed the cfile_name and
    cline from the mutex definition and moved them to a separate lookup table.
    This information is only used when there is a problem and is very rare but
    under normal operation they take up sizeof(void*) + sizeof(uint16_t) space,
    the sizeof(uint16_t) actually occupies 8 bytes due to the alignment. The size
    of the mutex was therefore 72 bytes. It has now been reduced to:
    
    We don't track the create file and line number for the block mutexes. There
    are just too many of them and they are all created in the same file(buf0buf.cc)
    and on the same line number, you can grep the code to figure that out.
    
      gdb) p sizeof(ib_mutex_t)
          $1 = 48
    
    For rw_lock_t, add a is_block_lock flag. This flag is set in buf0buf.cc where
    the block lock is created.
    
    Removed UNIV_SYNC_DEBUG. UNIV_DEBUG will by default do sync order checking.
    Add read-only debug config variable: --innodb-sync-debug (default: true).
    Potential use case is to run the latch ordering checks in the weekly tests
    if the overhead is too much for daily tests.
    
    Added dynamic enable/disable/reset of mutex/rw statistic gathering using
    the existing monitor infrastructure
    
        SET GLOBAL innodb_monitor_enable="latch";
        SET GLOBAL innodb_monitor_reset="latch";
        SET GLOBAL innodb_monitor_disable="latch";
    
    Added additonal information to the SHOW ... MUTEX OUTPUT
    
    mysql> show engine innodb mutex;
    +--------+-------------------------+------------------------------------------+
    | Type   | Name                    | Status                                   |
    +--------+-------------------------+------------------------------------------+
    | InnoDB | TRX_SYS                 | spins=3371806,waits=44790,calls=800875   |
    ...
    | InnoDB | rwlock: log0log.cc:784  | waits=3                                  |
    +--------+-------------------------+------------------------------------------+
    
    The "Name" columns will now display the mutex name and not the filename:line
    format which was very build specific. For RW-LOCKS we will stick with the old
    format.
    
    Fixed several bugs in the SyncDebug checks that were introduced in WL#6044.
    
    Moved the low level OS mutex to a separate class with a separate interface.
    We can't track these because they are implemented outside of InnoDB.
    
    Remove UNIV_DEBUG_FILE_ACCESSES, fold into UNIV_DEBUG
    
    Approved by Jimmy Yang and Bin Su rb#9037
Loading