Excessive and unneccessary current_thd usage in Percona Server
A call to _current_thd() is expensive, and some Percona patches use
current_thd unnecessarily, sometimes on critical code paths.
For example, benchmarks show that removing the following _current_thd()
call in innobase_
high-concurrency results by about 1k tps:
/* Save the current replication position for write to trx sys
header for undo purposes, see the comment at corresponding call
The THD pointer is available in trx->mysql_thd, there's no need to use
A quick inspection of the code shows there are many more unnecessary
current_thd occurrences in our code. Some of them are trivial to fix, while
others may require re-architecting certain features.