PS-11120 [trunk]: Reduce contention on BUF_BLOCK_MUTEX by reading ahead the access_time#6044
Open
polchawa-percona wants to merge 1 commit into
Open
PS-11120 [trunk]: Reduce contention on BUF_BLOCK_MUTEX by reading ahead the access_time#6044polchawa-percona wants to merge 1 commit into
polchawa-percona wants to merge 1 commit into
Conversation
…ad the access_time https://perconadev.atlassian.net/browse/PS-11120 This patch reduces contention inside buf_page_optimistic_get. We acquire the BUF_BLOCK_MUTEX twice there. The second time we acquire it only to update the access time, and only if it was zero. By reading the access time the first time we hold the mutex, we can skip re-acquiring it when the page has already been accessed (non-zero access time), which is the common case for hot pages. This is safe because: the second time the mutex is taken the access time is re-checked anyway; access time is never reset to zero (except when a page is reinitialized); and the page cannot be reinitialized meanwhile because it was buffer-fixed on first access. This is a contribution from Anna Glasgall <aglasgal@akamai.com> / Akamai, with a minor fix added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://perconadev.atlassian.net/browse/PS-11120
trunk equivalent of #6031.
This patch reduces contention inside
buf_page_optimistic_get. We acquire the BUF_BLOCK_MUTEX twice there, but the second time only to update the access time — and only if it was zero. By reading the access time the first time we hold the mutex, we can avoid re-acquiring it when the page has already been accessed (non-zero access time), which is the common case for hot pages.Why it is safe:
buf_block_buf_fix_inc) on first access and stays alive until unfixed.This is a contribution from Anna Glasgall aglasgal@akamai.com / Akamai, with a minor fix added.