[MDEV-26476] InnoDB is missing futex support on some platforms Created: 2021-08-25  Updated: 2023-11-13  Resolved: 2022-02-18

Status: Closed
Project: MariaDB Server
Component/s: Platform FreeBSD, Storage Engine - InnoDB
Affects Version/s: 10.6.0
Fix Version/s: 10.9.0, 10.6.8, 10.7.4, 10.8.3

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: performance, portability

Issue Links:
Relates
relates to MDEV-26781 InnoDB hangs on SPATIAL INDEX when us... Closed
relates to MDEV-32788 CMAKE_BUILD_TYPE=Debug build failure ... Closed
relates to MDEV-20612 Improve InnoDB lock_sys scalability Closed
relates to MDEV-25404 read-only performance regression in 10.6 Closed
relates to MDEV-27222 FreeBSD 13.0-p4 build error mariadb-1... Closed

 Description   

In MDEV-20612, MDEV-24142 and related tasks, the InnoDB synchronization primitives were rewritten. On Linux, Microsoft Windows, and OpenBSD, we make use of futex-like system calls. (On Microsoft Windows, srw_mutex and srw_lock are simple wrappers of SRWLOCK; on other platforms they are implemented with futexes.)

According to https://shift.click/blog/futex-like-apis/ there are a few more platforms that we should be able to support:

  • FreeBSD: _umtx_op (UMTX_OP_WAIT_UINT_PRIVATE, UMTX_OP_WAKE_PRIVATE)
  • DragonflyBSD: umtx_sleep, umtx_wakeup
  • Apple macOS: __ulock_wait, __ulock_wake

When futex support is missing, we will fall back to the SUX_LOCK_GENERIC implementation that is based on native mutexes, condition variables and native rw-locks when available. Not only will this increase the memory footprint, but lock_sys_t::hash_latch::release() could be a scalability bottleneck, because it uses a single mutex and condition variable to ‘emulate’ futex so that we can avoid increasing the memory footprint of lock_sys.rec_hash.

To be determined: Are any futex-like operations available on other operating systems where MariaDB Server might be able to run?

  • AIX
  • HP-UX
  • Solaris or its derivatives, such as Illumos or OpenIndiana


 Comments   
Comment by Marko Mäkelä [ 2022-02-18 ]

On DragonFly BSD v6.2.1, I had to apply the following patch to get MariaDB Server to compile:

diff --git a/client/mysql.cc b/client/mysql.cc
index 37f506a99cd..ad8fb9ccfa6 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -104,7 +104,7 @@ extern "C" {
 #define USE_POPEN
 }
 
-#ifdef HAVE_VIDATTR
+#if defined HAVE_VIDATTR && !defined __DragonFly__
 static int have_curses= 0;
 static void my_vidattr(chtype attrs)
 {

On FreeBSD 13, the compilation worked out of the box. On both systems, I successfully tested the implementation with

storage/innobase/unittest/innodb_sync-t
cd mysql-test
./mtr --parallel=8 --suite=innodb_gis --force

Without futex support, the test suite would have failed due to MDEV-26781.

Generated at Thu Feb 08 09:45:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.