diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-12-03 17:42:07 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-12-03 17:42:07 +0200 |
commit | e9f33b7760539e2ba60fb236fab8eaf0ce53ca4a (patch) | |
tree | e1feef4b13b5b0de7e7a3ab5a7e6fa1514ed8cf6 | |
parent | ba2d45dc540ff942ba11941800ee1aab749784ca (diff) | |
download | mariadb-git-e9f33b7760539e2ba60fb236fab8eaf0ce53ca4a.tar.gz |
MDEV-24142: Avoid block_lock alignment loss on 64-bit systems
sux_lock::recursive: Move right after the 32-bit sux_lock::lock.
This will reduce sizeof(block_lock) from 24 to 16 bytes on
64-bit systems with CMAKE_BUILD_TYPE=RelWithDebInfo. This may be
significant, because there will be one buf_block_t::lock for each
buffer pool page descriptor.
We still have some potential for savings, with sizeof(buf_page_t)==112
and sizeof(buf_block_t)==184 on a GNU/Linux AMD64 system.
Note: On GNU/Linux AMD64, sizeof(index_lock) remains 32 bytes
(16 with PLUGIN_PERFSCHEMA=NO) even tough it would fit in 24 bytes.
This is because sizeof(srw_lock) includes 4 bytes of padding
(to 16 bytes) that index_lock_t::recursive cannot reuse. So,
in total 4+4 bytes will be lost to padding. This is rather
insignificant compared to sizeof(dict_index_t)==400.
-rw-r--r-- | storage/innobase/include/srw_lock.h | 4 | ||||
-rw-r--r-- | storage/innobase/include/sux_lock.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/storage/innobase/include/srw_lock.h b/storage/innobase/include/srw_lock.h index 4102192a0aa..4f9af3c371c 100644 --- a/storage/innobase/include/srw_lock.h +++ b/storage/innobase/include/srw_lock.h @@ -114,8 +114,8 @@ typedef srw_lock_low srw_lock; /** Slim reader-writer lock with PERFORMANCE_SCHEMA instrumentation */ class srw_lock { - srw_lock_low lock; PSI_rwlock *pfs_psi; + srw_lock_low lock; template<bool support_u_lock> ATTRIBUTE_NOINLINE void psi_rd_lock(const char *file, unsigned line); @@ -126,8 +126,8 @@ class srw_lock public: void init(mysql_pfs_key_t key) { - lock.init(); pfs_psi= PSI_RWLOCK_CALL(init_rwlock)(key, this); + lock.init(); } void destroy() { diff --git a/storage/innobase/include/sux_lock.h b/storage/innobase/include/sux_lock.h index de5ca808fcc..4bb9448b91d 100644 --- a/storage/innobase/include/sux_lock.h +++ b/storage/innobase/include/sux_lock.h @@ -33,6 +33,8 @@ class sux_lock final { /** The underlying non-recursive lock */ srw lock; + /** Numbers of U and X locks. Protected by lock. */ + uint32_t recursive; /** The owner of the U or X lock (0 if none); protected by lock */ std::atomic<os_thread_id_t> writer; /** Special writer!=0 value to indicate that the lock is non-recursive @@ -42,8 +44,6 @@ class sux_lock final #else # define FOR_IO ((os_thread_id_t) ~0UL) /* it could be a pointer */ #endif - /** Numbers of U and X locks. Protected by lock. */ - uint32_t recursive; #ifdef UNIV_DEBUG /** Protects readers */ mutable srw_mutex readers_lock; |