MDEV-36190: Optimize transaction_lock_guard use #4188
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This also includes #4172 so that it could be more convenient to test both at the same time.
buf_pool_t::page_guess()
: Avoid a memory transaction, because we would be checking several conditions inside it.buf_pool_t::page_hash_table::lock_and_append()
: A new function, used in two places. Attempt to use a simple memory transaction for inserting the first bucket of a chain. For any more complex case, fall back to normal latching.buf_pool_t::page_hash_table::append()
: Define non-inline
.buf_pool_t::page_hash_table::replace()
,buf_pool_t::page_hash_table::remove()
: Move the inline definition to the compilation unit of the only caller, to declutter the header.buf_page_create_low()
: Invokebuf_page_t::set_state()
before inserting into thebuf_pool.page_hash
. It is safe to do this, because we are holdingbuf_pool.mutex
.Release Notes
On some Intel Xeon CPUs, performance was improved slightly.
How can this PR be tested?
Various performance test workloads on various CPU implementations that support hardware memory transactions. For x86-64, that would be Intel® Xeon® models.
Basing the PR against the correct MariaDB version
main
branch.This is a performance bug fix. The change to
buf_page_init_for_read()
depends on f27e9c8, and 11.4 is the oldest maintained branch that includes that change.PR quality check