MySQL 8.0.37
Source Code Documentation
service_thd_wait.h File Reference

This service provides functions for plugins and storage engines to report when they are going to sleep/stall. More...

Go to the source code of this file.

Classes

struct  thd_wait_service_st
 

Macros

#define MYSQL_THD   THD *
 

Typedefs

typedef enum _thd_wait_type_e thd_wait_type
 

Enumerations

enum  _thd_wait_type_e {
  THD_WAIT_SLEEP = 1 , THD_WAIT_DISKIO = 2 , THD_WAIT_ROW_LOCK = 3 , THD_WAIT_GLOBAL_LOCK = 4 ,
  THD_WAIT_META_DATA_LOCK = 5 , THD_WAIT_TABLE_LOCK = 6 , THD_WAIT_USER_LOCK = 7 , THD_WAIT_BINLOG = 8 ,
  THD_WAIT_GROUP_COMMIT = 9 , THD_WAIT_SYNC = 10 , THD_WAIT_LAST = 11
}
 

Functions

void thd_wait_begin (MYSQL_THD thd, int wait_type)
 Interface for MySQL Server, plugins and storage engines to report when they are going to sleep/stall. More...
 
void thd_wait_end (MYSQL_THD thd)
 Interface for MySQL Server, plugins and storage engines to report when they waking up from a sleep/stall. More...
 

Variables

struct thd_wait_service_stthd_wait_service
 

Detailed Description

This service provides functions for plugins and storage engines to report when they are going to sleep/stall.

SYNOPSIS thd_wait_begin() - call just before a wait begins thd Thread object Use NULL if the thd is NOT known. wait_type Type of wait 1 – short wait (e.g. for mutex) 2 – medium wait (e.g. for disk io) 3 – large wait (e.g. for locked row/table) NOTES This is used by the threadpool to have better knowledge of which threads that currently are actively running on CPUs. When a thread reports that it's going to sleep/stall, the threadpool scheduler is free to start another thread in the pool most likely. The expected wait time is simply an indication of how long the wait is expected to become, the real wait time could be very different.

thd_wait_end() called immediately after the wait is complete

thd_wait_end() MUST be called if thd_wait_begin() was called.

Using thd_wait_...() service is optional but recommended. Using it will improve performance as the thread pool will be more active at managing the thread workload.

Macro Definition Documentation

◆ MYSQL_THD

#define MYSQL_THD   THD *

Typedef Documentation

◆ thd_wait_type

Enumeration Type Documentation

◆ _thd_wait_type_e

Enumerator
THD_WAIT_SLEEP 
THD_WAIT_DISKIO 
THD_WAIT_ROW_LOCK 
THD_WAIT_GLOBAL_LOCK 
THD_WAIT_META_DATA_LOCK 
THD_WAIT_TABLE_LOCK 
THD_WAIT_USER_LOCK 
THD_WAIT_BINLOG 
THD_WAIT_GROUP_COMMIT 
THD_WAIT_SYNC 
THD_WAIT_LAST 

Function Documentation

◆ thd_wait_begin()

void thd_wait_begin ( MYSQL_THD  thd,
int  wait_type 
)

Interface for MySQL Server, plugins and storage engines to report when they are going to sleep/stall.

This is currently only implemented by by the threadpool and used to have better knowledge of which threads that currently are actively running on CPUs. When not running with TP this makes a call, possibly through a service, to an empty function.

thd_wait_end MUST be called immediately after waking up again.

More info can be found in the TP documentation.

Parameters
thdCalling thread context. If nullptr is passed, current_thd is used.
wait_typeAn enum value from the enum thd_wait_type (defined in include/mysql/service_thd_wait.h) but passed as int to preserve compatibility with exported service api.

◆ thd_wait_end()

void thd_wait_end ( MYSQL_THD  thd)

Interface for MySQL Server, plugins and storage engines to report when they waking up from a sleep/stall.

This is currently only implemented by by the threadpool and used to have better knowledge of which threads that currently are actively running on CPUs. When not running with TP this makes a call, possibly through a service, to an empty function.

More info can be found in the TP documentation.

Parameters
thdCalling thread context. If nullptr is passed, current_thd is used.

Variable Documentation

◆ thd_wait_service

struct thd_wait_service_st * thd_wait_service