Skip to content

MDEV-21423: Speed up lf_hash_iterate()#4886

Open
dr-m wants to merge 1 commit into10.11from
MDEV-21423
Open

MDEV-21423: Speed up lf_hash_iterate()#4886
dr-m wants to merge 1 commit into10.11from
MDEV-21423

Conversation

@dr-m
Copy link
Copy Markdown
Contributor

@dr-m dr-m commented Apr 1, 2026

  • The Jira issue number for this PR is: MDEV-21423

Description

The function lf_hash_iterate() can be very CPU intensive, especially in ReadView::open().

l_find(): Specialize the two distinct cases: callback or key lookup. The callback is only used by lf_hash_iterate().

Now that the callback variant of l_find() uses much fewer parameters and can be expanded inline, InnoDB trx_sys.rw_trx_hash iterations in ReadView::open() and elsewhere should become faster.

Release Notes

See the previous section.

How can this PR be tested?

This low-level code should be well covered by the existing regression tests. Pretty much any InnoDB test should invoke ReadView::open() or some MDL, which are some users of this code.

This should be best tested by HammerDB or Sysbench, using

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;

so that calls to ReadView::open() will be more frequent.

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

This performance bug fix is also applicable to the 10.6 branch. However, according to our current policy we only fix crash or corruption bugs in the 10.6 branch.

l_find(): Specialize the two distinct cases: callback or key.
The callback is only used by lf_hash_iterate(), which can be
a very CPU intensive function, especially in ReadView::open().
Now that the callback variant uses much fewer parameters and
can be expanded inline, InnoDB trx_sys.rw_trx_hash iterations
in ReadView::open() and elsewhere should become faster.
@dr-m dr-m requested a review from sanja-byelkin April 1, 2026 06:43
@dr-m dr-m self-assigned this Apr 1, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@svoj
Copy link
Copy Markdown
Contributor

svoj commented Apr 1, 2026

Dunno, it must bring some measurable performance improvement to make this code duplication worthy. Most probably it won't improve performance enough to consider those two famous jira issues fixed.

@vaintroub
Copy link
Copy Markdown
Member

vaintroub commented Apr 1, 2026

Yes @dr-m , please run the benchmarks, there are prominently featured in the bug report. And share your numbers. We can't guess whether it fixes anything. It needs confirmation before review, and most important, it should give you this confirmation. Not "This should be best tested by HammerDB or Sysbench", but "I tested and it brought 0.0002% performance improvement" or something similar

@dr-m
Copy link
Copy Markdown
Contributor Author

dr-m commented Apr 2, 2026

This comment in MDEV-21423 covers a test scenario that @vaintroub requested. I am observing an improvement of 3% in throughput in my test environment. The largest difference on this system that I observed was 9%, but that was in a shorter run.

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

Development

Successfully merging this pull request may close these issues.

4 participants