InnoDB uses its own mutexes and read-write locks instead of
POSIX-mutexes pthread_mutex*, the main reason for that is
performance, but InnoDB's implementation isn't ideal and on
modern SMP boxes can cause serious performance problems.
Let's look on InnoDB mutex (schematic for simplification):
PLAIN TEXT CODE:
- spin_loop:
- for (i=0; i<innodb_spin_locks;i++)
- if (mutex_try_lock()) return; // success
- // we are here if spin loop was not successful
- reserve_cell in array of cell;
- wait on condition_variable in reserved cell;
innodb_spin_locks is configurable via system variable innodb_sync_spin_loops (default value is 20)
There we have:
1. Spin-loop - InnoDB uses spin-loop in hopes thread locked mutex
is very fast and will release mutex while current thread runs in …