MySQL 8.0.39
Source Code Documentation
|
Implementation of read-write lock partitioned by thread id. More...
#include <partitioned_rwlock.h>
Public Member Functions | |
Partitioned_rwlock ()=default | |
bool | init (uint parts, PSI_rwlock_key psi_key) |
void | destroy () |
void | wrlock () |
void | wrunlock () |
void | rdlock (uint thread_id) |
void | rdunlock (uint thread_id) |
Private Member Functions | |
Partitioned_rwlock (const Partitioned_rwlock &) | |
Partitioned_rwlock & | operator= (const Partitioned_rwlock &) |
Private Attributes | |
mysql_rwlock_t * | m_locks_array |
uint | m_parts |
Implementation of read-write lock partitioned by thread id.
This rwlock provides better scalability in read-heavy environments by employing the following simple trick: ) Read lock is acquired only on one of its partitions. The specific partition is chosen according to thread id. ) Write lock is acquired on all partitions.
This way concurrent request for read lock made by different threads have a good chance not to disturb each other by doing cache invalidation and atomic operations. As result scalability in this scenario improves. OTOH acquisition of write lock becomes more expensive. So this rwlock is not supposed to be used in cases when number of write requests is significant.
|
default |
|
private |
|
inline |
|
inline |
parts | Number of partitions. |
psi_key | P_S instrumentation key to use for rwlock instances for partitions. |
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |