[MDEV-32065] Always check whether lock is free at first to optimize InnoDB mutexes Created: 2023-09-01 Updated: 2023-10-04 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | yuhanyang | Assignee: | Marko Mäkelä |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | innodb, performance | ||
| Attachments: |
|
||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
`try_lock()` in InnoDB codes is an atomic operation. For example, it's compiled to "lock cmpxchg" in x86. It will force cacheline to be exclusive state and suffer significant performance degradation in heavy contended scenarios when many CPUs `try_lock()`. I collected a perf report and it's assembly codes in my benchmark. Attach them in files. Look at the TTASEventMutex implementation, for instance. We mark the codes, always check whether lock is free at first, then `try_lock()`.
Based on real real-world workload test on a 224 CPUs x86 server, this change |
| Comments |
| Comment by Marko Mäkelä [ 2023-09-01 ] |
|
The last release of MariaDB Server 10.3 was 10.3.39 that was released on May 2, 2023. In MariaDB Server 10.6, the InnoDB synchronization primitives were replaced or rewritten in In Compiler support has evolved too, both in GCC and clang. https://github.com/llvm/llvm-project/issues/58685 is one example. |
| Comment by Marko Mäkelä [ 2023-09-01 ] |
|
Can you suggest any improvement to MariaDB Server 10.6 or later? The last significant architectural performance improvement in InnoDB was |
| Comment by yuhanyang [ 2023-09-01 ] |
|
Thank you for you quick reponse and warm heart comments. |
| Comment by Marko Mäkelä [ 2023-09-01 ] |
|
Thank you for the explanation. MariaDB provides also its own packages for major GNU/Linux distributions. You can find a repository for Ubuntu 20.04 at https://mariadb.org/download/?t=repo-config. We actually use Ubuntu 20.04 on some internal test systems. Its Linux kernel is just new enough to support io_uring ( |
| Comment by yuhanyang [ 2023-09-04 ] |
|
Hi, Marko |
| Comment by yuhanyang [ 2023-09-04 ] |
|
By the way, I used mariaDB10.6 to do the benchmark. |