MySQL 8.0.0 split the InnoDB buf_pool_t::mutex. MariaDB should do something similar.
Instead of introducing more mutexes or radically changing the latching rules of various buf_pool_t and buf_block_t data members, I think that it is possible to reduce the contention on buf_pool.mutex by other means:
- Move more code to inline functions of buf_pool_t or buf_page_t.
- Reduce the amount of mutex release/reacquire dance in buf0flu.cc and buf0rea.cc.
- Avoid repeated calls to page_id_t::fold() or page_id_t::page_id_t(); use page_id_t directly as loop iterator.
- Move buf_page_t::flush_type to IORequest.
- Split buf_page_io_complete() into separate ‘read completion’ and ‘write completion’ callbacks.
- Avoid holding buf_pool.mutex during buf_pool.page_hash operations. Consider removing the debug field buf_page_t::in_page_hash.
- Split operations on buf_pool.watch into two parts. The allocation of buf_pool.watch should be only protected by buf_pool.mutex, and the buf_pool.page_hash only by the hash bucket latch.