Skip to content

PS-11120 [9.7]: Reduce contention on BUF_BLOCK_MUTEX by reading ahead the access_time#6031

Open
polchawa-percona wants to merge 1 commit into
percona:9.7from
polchawa-percona:PS-11120-9.7
Open

PS-11120 [9.7]: Reduce contention on BUF_BLOCK_MUTEX by reading ahead the access_time#6031
polchawa-percona wants to merge 1 commit into
percona:9.7from
polchawa-percona:PS-11120-9.7

Conversation

@polchawa-percona

Copy link
Copy Markdown
Contributor

https://perconadev.atlassian.net/browse/PS-11120

This patch reduces contention inside buf_page_optimistic_get. We acquire the BUF_BLOCK_MUTEX twice there. But the second time we acquire it only to update the access time. Given that we would update the access time only if it was zero, we could avoid acquiring the mutex when we knew that the access time was already non-zero. This we could learn the first time we acquired the mutex by reading the access time field of the page.

Note:

the second time we acquired the mutex, we would check again if it still was zero anyway
we never reset the access time to zero (unless we reinitialize new page)
the page would not be reinitialized meanwhile, because the first time we accessed it, we "fix it" (call buf_block_buf_fix_inc), which is to keep the page alive (purpose of fixing) until it is "unfixed" (much later)
The patch is safe and allows us to save a significant number of times we needed to acquire the mutex.

This is a contribution from: Anna Glasgall aglasgal@akamai.com / Akamai, with a minor fix added.

…ccess_time

This patch reduces contention inside buf_page_optimistic_get. We acquire there
the BUF_BLOCK_MUTEX twice. But the second time we acquire only to update the
access time. Given that we would update the access time only if it was zero,
we could avoid acquiring the mutex when we knew that the access time was already
non-zero. This we could learn the first time we acquired the mutex by reading
the access time field of the page.

Note: the second time we acquired the mutex, we re-check if it still was zero
anyway, so the patch is safe and allows to save significant number of times
we needed to acquire the mutex.

This is a contribution from: Anna Glasgall (with a minor fix).
@polchawa-percona polchawa-percona self-assigned this Jun 24, 2026
@polchawa-percona polchawa-percona changed the base branch from 8.4 to 9.7 June 24, 2026 10:22

@satya-bodapati satya-bodapati left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants