For the complete documentation index, see llms.txt. This page is also available as Markdown.

Thread Instrumentation

Instrumented mutex, rwlock, prlock, and condition structures and their wrappers, and the PSI_CALL_* thread macros that register threads and set their attributes.

Instrumentation Interface

Classes

Name
Description

An instrumented mutex structure. See also: mysql_mutex_t

An instrumented rwlock structure. See also: mysql_rwlock_t

An instrumented prlock structure. See also: mysql_prlock_t

An instrumented cond structure. See also: mysql_cond_t

Macros

Name
Description

Wrapper, to use safe_mutex_assert_owner with instrumented mutexes. mysql_mutex_assert_owner is a drop-in replacement for safe_mutex_assert_owner.

Wrapper, to use safe_mutex_assert_not_owner with instrumented mutexes. mysql_mutex_assert_not_owner is a drop-in replacement for safe_mutex_assert_not_owner.

Drop-in replacement for rw_pr_lock_assert_write_owner.

Drop-in replacement for rw_pr_lock_assert_not_write_owner.

Mutex registration.

Instrumented mutex_init. mysql_mutex_init is a replacement for pthread_mutex_init.

Instrumented mutex_destroy. mysql_mutex_destroy is a drop-in replacement for pthread_mutex_destroy.

Instrumented mutex_lock. mysql_mutex_lock is a drop-in replacement for pthread_mutex_lock.

Instrumented mutex_lock. mysql_mutex_trylock is a drop-in replacement for pthread_mutex_trylock.

Instrumented mutex_unlock. mysql_mutex_unlock is a drop-in replacement for pthread_mutex_unlock.

Rwlock registration.

Instrumented rwlock_init. mysql_rwlock_init is a replacement for pthread_rwlock_init. Note that pthread_rwlockattr_t is not supported in MySQL.

Instrumented rw_pr_init. mysql_prlock_init is a replacement for rw_pr_init.

Instrumented rwlock_destroy. mysql_rwlock_destroy is a drop-in replacement for pthread_rwlock_destroy.

Instrumented rw_pr_destroy. mysql_prlock_destroy is a drop-in replacement for rw_pr_destroy.

Instrumented rwlock_rdlock. mysql_rwlock_rdlock is a drop-in replacement for pthread_rwlock_rdlock.

Instrumented rw_pr_rdlock. mysql_prlock_rdlock is a drop-in replacement for rw_pr_rdlock.

Instrumented rwlock_wrlock. mysql_rwlock_wrlock is a drop-in replacement for pthread_rwlock_wrlock.

Instrumented rw_pr_wrlock. mysql_prlock_wrlock is a drop-in replacement for rw_pr_wrlock.

Instrumented rwlock_tryrdlock. mysql_rwlock_tryrdlock is a drop-in replacement for pthread_rwlock_tryrdlock.

Instrumented rwlock_trywrlock. mysql_rwlock_trywrlock is a drop-in replacement for pthread_rwlock_trywrlock.

Instrumented rwlock_unlock. mysql_rwlock_unlock is a drop-in replacement for pthread_rwlock_unlock.

Instrumented rw_pr_unlock. mysql_prlock_unlock is a drop-in replacement for rw_pr_unlock.

Cond registration.

Instrumented cond_init. mysql_cond_init is a replacement for pthread_cond_init.

Instrumented cond_destroy. mysql_cond_destroy is a drop-in replacement for pthread_cond_destroy.

Instrumented cond_wait. mysql_cond_wait is a drop-in replacement for pthread_cond_wait.

Instrumented cond_timedwait. mysql_cond_timedwait is a drop-in replacement for pthread_cond_timedwait.

Instrumented cond_signal. mysql_cond_signal is a drop-in replacement for pthread_cond_signal.

Instrumented cond_broadcast. mysql_cond_broadcast is a drop-in replacement for pthread_cond_broadcast.

Thread registration.

Instrumented pthread_create. This function creates both the thread instrumentation and a thread. mysql_thread_create is a replacement for pthread_create. The parameter P4 (or, if it is NULL, P1) will be used as the instrumented thread "identity". Providing a P1 / P4 parameter with a different value for each call will on average improve performances, since this thread identity value is used internally to randomize access to data and prevent contention. This is optional, and the improvement is not guaranteed, only statistical.

Set the thread identifier for the instrumentation.

Set the thread sql session for the instrumentation.


PSI_CALL_delete_current_thread

Defined in psi/mysql_thread.h:111


PSI_CALL_get_thread

Defined in psi/mysql_thread.h:112


PSI_CALL_new_thread

Defined in psi/mysql_thread.h:113


PSI_CALL_register_thread

Defined in psi/mysql_thread.h:114


PSI_CALL_set_thread

Defined in psi/mysql_thread.h:115


PSI_CALL_set_thread_THD

Defined in psi/mysql_thread.h:116


PSI_CALL_set_thread_connect_attrs

Defined in psi/mysql_thread.h:117


PSI_CALL_set_thread_db

Defined in psi/mysql_thread.h:118


PSI_CALL_set_thread_id

Defined in psi/mysql_thread.h:119


PSI_CALL_set_thread_os_id

Defined in psi/mysql_thread.h:120


PSI_CALL_set_thread_info

Defined in psi/mysql_thread.h:121


PSI_CALL_set_thread_start_time

Defined in psi/mysql_thread.h:122


PSI_CALL_set_thread_account

Defined in psi/mysql_thread.h:123


PSI_CALL_spawn_thread

Defined in psi/mysql_thread.h:124


PSI_CALL_set_connection_type

Defined in psi/mysql_thread.h:125


mysql_mutex_is_owner

Defined in psi/mysql_thread.h:266


mysql_mutex_assert_owner

Defined in psi/mysql_thread.h:273

Wrapper, to use safe_mutex_assert_owner with instrumented mutexes. mysql_mutex_assert_owner is a drop-in replacement for safe_mutex_assert_owner.


mysql_mutex_assert_not_owner

Defined in psi/mysql_thread.h:282

Wrapper, to use safe_mutex_assert_not_owner with instrumented mutexes. mysql_mutex_assert_not_owner is a drop-in replacement for safe_mutex_assert_not_owner.


mysql_mutex_setflags

Defined in psi/mysql_thread.h:285


mysql_prlock_assert_write_owner

Defined in psi/mysql_thread.h:293

Drop-in replacement for rw_pr_lock_assert_write_owner.


mysql_prlock_assert_not_write_owner

Defined in psi/mysql_thread.h:301

Drop-in replacement for rw_pr_lock_assert_not_write_owner.


mysql_mutex_register

Defined in psi/mysql_thread.h:308

Mutex registration.


mysql_mutex_init

Defined in psi/mysql_thread.h:333

Instrumented mutex_init. mysql_mutex_init is a replacement for pthread_mutex_init.

Parameters

Parameter
Type
Description

K

The PSI_mutex_key for this instrumented mutex

M

The mutex to initialize

A

Mutex attributes

K

The PSI_mutex_key for this instrumented mutex

M

The mutex to initialize

A

Mutex attributes


mysql_mutex_destroy

Defined in psi/mysql_thread.h:348

Instrumented mutex_destroy. mysql_mutex_destroy is a drop-in replacement for pthread_mutex_destroy.


mysql_mutex_lock

Defined in psi/mysql_thread.h:363

Instrumented mutex_lock. mysql_mutex_lock is a drop-in replacement for pthread_mutex_lock.

Parameters

Parameter
Type
Description

M

The mutex to lock

M

The mutex to lock


mysql_mutex_trylock

Defined in psi/mysql_thread.h:378

Instrumented mutex_lock. mysql_mutex_trylock is a drop-in replacement for pthread_mutex_trylock.


mysql_mutex_unlock

Defined in psi/mysql_thread.h:391

Instrumented mutex_unlock. mysql_mutex_unlock is a drop-in replacement for pthread_mutex_unlock.


mysql_rwlock_register

Defined in psi/mysql_thread.h:399

Rwlock registration.


mysql_rwlock_init

Defined in psi/mysql_thread.h:413

Instrumented rwlock_init. mysql_rwlock_init is a replacement for pthread_rwlock_init. Note that pthread_rwlockattr_t is not supported in MySQL.

Parameters

Parameter
Type
Description

K

The PSI_rwlock_key for this instrumented rwlock

RW

The rwlock to initialize

K

The PSI_rwlock_key for this instrumented rwlock

RW

The rwlock to initialize


mysql_prlock_init

Defined in psi/mysql_thread.h:426

Instrumented rw_pr_init. mysql_prlock_init is a replacement for rw_pr_init.

Parameters

Parameter
Type
Description

K

The PSI_rwlock_key for this instrumented prlock

RW

The prlock to initialize

K

The PSI_rwlock_key for this instrumented prlock

RW

The prlock to initialize


mysql_rwlock_destroy

Defined in psi/mysql_thread.h:435

Instrumented rwlock_destroy. mysql_rwlock_destroy is a drop-in replacement for pthread_rwlock_destroy.


mysql_prlock_destroy

Defined in psi/mysql_thread.h:443

Instrumented rw_pr_destroy. mysql_prlock_destroy is a drop-in replacement for rw_pr_destroy.


mysql_rwlock_rdlock

Defined in psi/mysql_thread.h:455

Instrumented rwlock_rdlock. mysql_rwlock_rdlock is a drop-in replacement for pthread_rwlock_rdlock.


mysql_prlock_rdlock

Defined in psi/mysql_thread.h:469

Instrumented rw_pr_rdlock. mysql_prlock_rdlock is a drop-in replacement for rw_pr_rdlock.


mysql_rwlock_wrlock

Defined in psi/mysql_thread.h:483

Instrumented rwlock_wrlock. mysql_rwlock_wrlock is a drop-in replacement for pthread_rwlock_wrlock.


mysql_prlock_wrlock

Defined in psi/mysql_thread.h:497

Instrumented rw_pr_wrlock. mysql_prlock_wrlock is a drop-in replacement for rw_pr_wrlock.


mysql_rwlock_tryrdlock

Defined in psi/mysql_thread.h:511

Instrumented rwlock_tryrdlock. mysql_rwlock_tryrdlock is a drop-in replacement for pthread_rwlock_tryrdlock.


mysql_rwlock_trywrlock

Defined in psi/mysql_thread.h:525

Instrumented rwlock_trywrlock. mysql_rwlock_trywrlock is a drop-in replacement for pthread_rwlock_trywrlock.


mysql_rwlock_unlock

Defined in psi/mysql_thread.h:535

Instrumented rwlock_unlock. mysql_rwlock_unlock is a drop-in replacement for pthread_rwlock_unlock.


mysql_prlock_unlock

Defined in psi/mysql_thread.h:543

Instrumented rw_pr_unlock. mysql_prlock_unlock is a drop-in replacement for rw_pr_unlock.


mysql_cond_register

Defined in psi/mysql_thread.h:549

Cond registration.


mysql_cond_init

Defined in psi/mysql_thread.h:563

Instrumented cond_init. mysql_cond_init is a replacement for pthread_cond_init.

Parameters

Parameter
Type
Description

K

The PSI_cond_key for this instrumented cond

C

The cond to initialize

A

Condition attributes

K

The PSI_cond_key for this instrumented cond

C

The cond to initialize

A

Condition attributes


mysql_cond_destroy

Defined in psi/mysql_thread.h:571

Instrumented cond_destroy. mysql_cond_destroy is a drop-in replacement for pthread_cond_destroy.


mysql_cond_wait

Defined in psi/mysql_thread.h:582

Instrumented cond_wait. mysql_cond_wait is a drop-in replacement for pthread_cond_wait.


mysql_cond_timedwait

Defined in psi/mysql_thread.h:596

Instrumented cond_timedwait. mysql_cond_timedwait is a drop-in replacement for pthread_cond_timedwait.


mysql_cond_signal

Defined in psi/mysql_thread.h:605

Instrumented cond_signal. mysql_cond_signal is a drop-in replacement for pthread_cond_signal.


mysql_cond_broadcast

Defined in psi/mysql_thread.h:613

Instrumented cond_broadcast. mysql_cond_broadcast is a drop-in replacement for pthread_cond_broadcast.


mysql_thread_register

Defined in psi/mysql_thread.h:619

Thread registration.


mysql_thread_create

Defined in psi/mysql_thread.h:643

Instrumented pthread_create. This function creates both the thread instrumentation and a thread. mysql_thread_create is a replacement for pthread_create. The parameter P4 (or, if it is NULL, P1) will be used as the instrumented thread "identity". Providing a P1 / P4 parameter with a different value for each call will on average improve performances, since this thread identity value is used internally to randomize access to data and prevent contention. This is optional, and the improvement is not guaranteed, only statistical.

Parameters

Parameter
Type
Description

K

The PSI_thread_key for this instrumented thread

P1

pthread_create parameter 1

P2

pthread_create parameter 2

P3

pthread_create parameter 3

P4

pthread_create parameter 4

K

The PSI_thread_key for this instrumented thread

P1

pthread_create parameter 1

P2

pthread_create parameter 2

P3

pthread_create parameter 3

P4

pthread_create parameter 4


mysql_thread_set_psi_id

Defined in psi/mysql_thread.h:655

Set the thread identifier for the instrumentation.

Parameters

Parameter
Type
Description

I

The thread identifier

I

The thread identifier


mysql_thread_set_psi_THD

Defined in psi/mysql_thread.h:666

Set the thread sql session for the instrumentation.

Parameters

Parameter
Type
Description

T

The thread identifier

T

The thread identifier

Typedefs

Return
Name
Description

Type of an instrumented mutex. mysql_mutex_t is a drop-in replacement for pthread_mutex_t. See also: mysql_mutex_assert_owner

Type of an instrumented rwlock. mysql_rwlock_t is a drop-in replacement for pthread_rwlock_t. See also: mysql_rwlock_init

Type of an instrumented prlock. A prlock is a read write lock that 'prefers readers' (pr). mysql_prlock_t is a drop-in replacement for rw_pr_lock_t. See also: mysql_prlock_init

Type of an instrumented condition. mysql_cond_t is a drop-in replacement for pthread_cond_t. See also: mysql_cond_init


mysql_mutex_t

Type: struct st_mysql_mutex

Defined in psi/mysql_thread.h:159

Type of an instrumented mutex. mysql_mutex_t is a drop-in replacement for pthread_mutex_t. See also: mysql_mutex_assert_owner

See also: mysql_mutex_assert_not_owner

See also: mysql_mutex_init

See also: mysql_mutex_lock

See also: mysql_mutex_unlock

See also: mysql_mutex_destroy


mysql_rwlock_t

Type: struct st_mysql_rwlock

Defined in psi/mysql_thread.h:204

Type of an instrumented rwlock. mysql_rwlock_t is a drop-in replacement for pthread_rwlock_t. See also: mysql_rwlock_init

See also: mysql_rwlock_rdlock

See also: mysql_rwlock_tryrdlock

See also: mysql_rwlock_wrlock

See also: mysql_rwlock_trywrlock

See also: mysql_rwlock_unlock

See also: mysql_rwlock_destroy


mysql_prlock_t

Type: struct st_mysql_prlock

Defined in psi/mysql_thread.h:216

Type of an instrumented prlock. A prlock is a read write lock that 'prefers readers' (pr). mysql_prlock_t is a drop-in replacement for rw_pr_lock_t. See also: mysql_prlock_init

See also: mysql_prlock_rdlock

See also: mysql_prlock_wrlock

See also: mysql_prlock_unlock

See also: mysql_prlock_destroy


mysql_cond_t

Type: struct st_mysql_cond

Defined in psi/mysql_thread.h:244

Type of an instrumented condition. mysql_cond_t is a drop-in replacement for pthread_cond_t. See also: mysql_cond_init

See also: mysql_cond_wait

See also: mysql_cond_timedwait

See also: mysql_cond_signal

See also: mysql_cond_broadcast

See also: mysql_cond_destroy

Functions

Return
Name
Description

inline_mysql_mutex_register

static inline

Defined in psi/mysql_thread.h:669


inline_mysql_mutex_init

static inline

Defined in psi/mysql_thread.h:686


inline_mysql_mutex_destroy

static inline

Defined in psi/mysql_thread.h:709


inline_mysql_mutex_lock

static inline

Defined in psi/mysql_thread.h:737


inline_mysql_mutex_trylock

static inline

Defined in psi/mysql_thread.h:756


inline_mysql_mutex_unlock

static inline

Defined in psi/mysql_thread.h:775


inline_mysql_rwlock_register

static inline

Defined in psi/mysql_thread.h:798


inline_mysql_rwlock_init

static inline

Defined in psi/mysql_thread.h:815


inline_mysql_prlock_init

static inline

Defined in psi/mysql_thread.h:833


inline_mysql_rwlock_destroy

static inline

Defined in psi/mysql_thread.h:848


inline_mysql_prlock_destroy

static inline

Defined in psi/mysql_thread.h:862


inline_mysql_rwlock_rdlock

static inline

Defined in psi/mysql_thread.h:893


inline_mysql_prlock_rdlock

static inline

Defined in psi/mysql_thread.h:908


inline_mysql_rwlock_wrlock

static inline

Defined in psi/mysql_thread.h:923


inline_mysql_prlock_wrlock

static inline

Defined in psi/mysql_thread.h:938


inline_mysql_rwlock_tryrdlock

static inline

Defined in psi/mysql_thread.h:953


inline_mysql_rwlock_trywrlock

static inline

Defined in psi/mysql_thread.h:967


inline_mysql_rwlock_unlock

static inline

Defined in psi/mysql_thread.h:981


inline_mysql_prlock_unlock

static inline

Defined in psi/mysql_thread.h:994


inline_mysql_cond_register

static inline

Defined in psi/mysql_thread.h:1007


inline_mysql_cond_init

static inline

Defined in psi/mysql_thread.h:1024


inline_mysql_cond_destroy

static inline

Defined in psi/mysql_thread.h:1039


inline_mysql_cond_wait

static inline

Defined in psi/mysql_thread.h:1060


inline_mysql_cond_timedwait

static inline

Defined in psi/mysql_thread.h:1075


inline_mysql_cond_signal

static inline

Defined in psi/mysql_thread.h:1091


inline_mysql_cond_broadcast

static inline

Defined in psi/mysql_thread.h:1103


inline_mysql_thread_register

static inline

Defined in psi/mysql_thread.h:1115

Class Definitions

st_mysql_mutex

Defined in psi/mysql_thread.h:133

An instrumented mutex structure. See also: mysql_mutex_t

Public Attributes

Return
Name
Description

pthread_mutex_t

The real mutex.

struct PSI_mutex *

The instrumentation hook. Note that this hook is not conditionally defined, for binary compatibility of the mysql_mutex_t interface.


m_mutex

Defined in psi/mysql_thread.h:139

The real mutex.


m_psi

Type: struct PSI_mutex *

Defined in psi/mysql_thread.h:146

The instrumentation hook. Note that this hook is not conditionally defined, for binary compatibility of the mysql_mutex_t interface.

st_mysql_rwlock

Defined in psi/mysql_thread.h:165

An instrumented rwlock structure. See also: mysql_rwlock_t

Public Attributes

Return
Name
Description

rw_lock_t

The real rwlock

struct PSI_rwlock *

The instrumentation hook. Note that this hook is not conditionally defined, for binary compatibility of the mysql_rwlock_t interface.


m_rwlock

Defined in psi/mysql_thread.h:168

The real rwlock


m_psi

Type: struct PSI_rwlock *

Defined in psi/mysql_thread.h:174

The instrumentation hook. Note that this hook is not conditionally defined, for binary compatibility of the mysql_rwlock_t interface.

st_mysql_prlock

Defined in psi/mysql_thread.h:181

An instrumented prlock structure. See also: mysql_prlock_t

Public Attributes

Return
Name
Description

rw_pr_lock_t

The real prlock

struct PSI_rwlock *

The instrumentation hook. Note that this hook is not conditionally defined, for binary compatibility of the mysql_rwlock_t interface.


m_prlock

Defined in psi/mysql_thread.h:184

The real prlock


m_psi

Type: struct PSI_rwlock *

Defined in psi/mysql_thread.h:190

The instrumentation hook. Note that this hook is not conditionally defined, for binary compatibility of the mysql_rwlock_t interface.

st_mysql_cond

Defined in psi/mysql_thread.h:222

An instrumented cond structure. See also: mysql_cond_t

Public Attributes

Return
Name
Description

pthread_cond_t

The real condition

struct PSI_cond *

The instrumentation hook. Note that this hook is not conditionally defined, for binary compatibility of the mysql_cond_t interface.


m_cond

Defined in psi/mysql_thread.h:225

The real condition


m_psi

Type: struct PSI_cond *

Defined in psi/mysql_thread.h:231

The instrumentation hook. Note that this hook is not conditionally defined, for binary compatibility of the mysql_cond_t interface.

Last updated

Was this helpful?