XtraDB Priority Mutex

Registered by Laurynas Biveinis

Implement a priority mutex. It is in every aspect the same as the regular ib_mutex_t, with the difference that waiters can designated as low priority (the default), or high priority. Then, upon a mutex exit with waiters present, only the high priority waiters will be signalled if there is at least one of them. If only low-priority waiters are present, then they will be signalled.

Such design would be unsafe for general use as there are no protections from starving low-priority threads indefinitely. However, it's OK for the InnoDB utility threads as all of them throttle themselves. Another potential issue is that low priority threads can still acquire the mutex before the high priority threads through the spinning in the time window between the high-priority waiters waking up and locking the mutex. This may be addressed in follow-up if needed.

The priority mutex is implemented as a new separate mutex type instead of blanket-converting all of the InnoDB mutexes. Even though it increases the patch size, it appears to be a better option because 1) the performance effect of blanket conversion has not been tested and it is possible that for mutexes that don't need it it's pure overhead; 2) the blanket conversion would convert all the buffer pool block mutexes, increasing the memory consumption significantly yet mostly needlessly.

To minimize the patch size, priority mutex API is new C++ overloads for regular mutex API for mutex_exit, mutex_own, mutex_create, mutex_free, mutex_enter_nowait. For mutex acquisition the overloaded [pfs_]mutex_enter_func function has a new extra parameter that can specify high, low, or default priority with default arg value as default priority. In the last case, the thread priority flag is used. The other two options are needed for mutexes whose priorities should differ from their thread priority.

Convert the following mutexes to priority mutex: dict_sys, LRU list, rseg, log, hash table sync object array. Other mutexes might be converted later as needed.

Blueprint information

Alexey Kopytov
Laurynas Biveinis
Laurynas Biveinis
Series goal:
Accepted for 5.6
Milestone target:
milestone icon 5.6.13-61.0
Started by
Laurynas Biveinis
Completed by
Laurynas Biveinis



Work Items

Dependency tree

* Blueprints in grey have been implemented.

This blueprint contains Public information 
Everyone can see this information.