Skip to content

Instantly share code, notes, and snippets.

@mdcallag
Created August 8, 2024 00:37
Show Gist options
  • Save mdcallag/8ecfe34120b25cd6e78e550fb45bc3ba to your computer and use it in GitHub Desktop.
Save mdcallag/8ecfe34120b25cd6e78e550fb45bc3ba to your computer and use it in GitHub Desktop.
/******************************************************************//**
Save some CPU by testing the value of srv_thread_concurrency in inline
functions. */
static inline
void
innobase_srv_conc_enter_innodb(
/*===========================*/
trx_t* trx) /*!< in: transaction handle */
{
if (srv_thread_concurrency) {
if (trx->n_tickets_to_enter_innodb > 0) {
/* If trx has 'free tickets' to enter the engine left,
then use one such ticket */
--trx->n_tickets_to_enter_innodb;
} else if (trx->mysql_thd != NULL
&& thd_is_replication_slave_thread(trx->mysql_thd)) {
UT_WAIT_FOR(
srv_conc_get_active_threads()
< srv_thread_concurrency,
srv_replication_delay * 1000);
} else {
srv_conc_enter_innodb(trx);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment