From ce559a77cf0cdc83a562717c6d3c15cb90ede1c2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 20 Sep 2024 10:34:44 +0200 Subject: [PATCH] MDEV-34973: innobase/dict0dict: add `noexcept` to lock/unlock methods Another chance for cutting back overhead due to C++ exceptions being enabled; the `dict_sys_t` class is a good candidate because its locking methods are called frequently. Binary size reduction this time: text data bss dec hex filename 24448622 2436488 9473537 36358647 22ac9f7 build/release/sql/mariadbd 24448474 2436488 9473601 36358563 22ac9a3 build/release/sql/mariadbd --- storage/innobase/dict/dict0dict.cc | 8 ++++---- storage/innobase/include/dict0dict.h | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 3c6d1ce9e48e9..70afa0a30f3c5 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -955,7 +955,7 @@ void dict_sys_t::create() } -void dict_sys_t::lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) +void dict_sys_t::lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept { ulonglong now= my_hrtime_coarse().val, old= 0; if (latch_ex_wait_start.compare_exchange_strong @@ -981,17 +981,17 @@ void dict_sys_t::lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) } #ifdef UNIV_PFS_RWLOCK -ATTRIBUTE_NOINLINE void dict_sys_t::unlock() +ATTRIBUTE_NOINLINE void dict_sys_t::unlock() noexcept { latch.wr_unlock(); } -ATTRIBUTE_NOINLINE void dict_sys_t::freeze(const char *file, unsigned line) +ATTRIBUTE_NOINLINE void dict_sys_t::freeze(const char *file, unsigned line) noexcept { latch.rd_lock(file, line); } -ATTRIBUTE_NOINLINE void dict_sys_t::unfreeze() +ATTRIBUTE_NOINLINE void dict_sys_t::unfreeze() noexcept { latch.rd_unlock(); } diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index a62a1ec004e18..b9a8c0e70e7e1 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -1493,24 +1493,24 @@ class dict_sys_t #ifdef UNIV_DEBUG /** @return whether the current thread is holding the latch */ - bool frozen() const { return latch.have_any(); } + bool frozen() const noexcept { return latch.have_any(); } /** @return whether the current thread is holding a shared latch */ - bool frozen_not_locked() const { return latch.have_rd(); } + bool frozen_not_locked() const noexcept { return latch.have_rd(); } /** @return whether the current thread holds the exclusive latch */ - bool locked() const { return latch.have_wr(); } + bool locked() const noexcept { return latch.have_wr(); } #endif private: /** Acquire the exclusive latch */ ATTRIBUTE_NOINLINE - void lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)); + void lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept; public: /** @return the my_hrtime_coarse().val of the oldest lock_wait() start, assuming that requests are served on a FIFO basis */ - ulonglong oldest_wait() const + ulonglong oldest_wait() const noexcept { return latch_ex_wait_start.load(std::memory_order_relaxed); } /** Exclusively lock the dictionary cache. */ - void lock(SRW_LOCK_ARGS(const char *file, unsigned line)) + void lock(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept { if (!latch.wr_lock_try()) lock_wait(SRW_LOCK_ARGS(file, line)); @@ -1518,18 +1518,18 @@ class dict_sys_t #ifdef UNIV_PFS_RWLOCK /** Unlock the data dictionary cache. */ - ATTRIBUTE_NOINLINE void unlock(); + ATTRIBUTE_NOINLINE void unlock() noexcept; /** Acquire a shared lock on the dictionary cache. */ - ATTRIBUTE_NOINLINE void freeze(const char *file, unsigned line); + ATTRIBUTE_NOINLINE void freeze(const char *file, unsigned line) noexcept; /** Release a shared lock on the dictionary cache. */ - ATTRIBUTE_NOINLINE void unfreeze(); + ATTRIBUTE_NOINLINE void unfreeze() noexcept; #else /** Unlock the data dictionary cache. */ - void unlock() { latch.wr_unlock(); } + void unlock() noexcept { latch.wr_unlock(); } /** Acquire a shared lock on the dictionary cache. */ - void freeze() { latch.rd_lock(); } + void freeze() noexcept { latch.rd_lock(); } /** Release a shared lock on the dictionary cache. */ - void unfreeze() { latch.rd_unlock(); } + void unfreeze() noexcept { latch.rd_unlock(); } #endif /** Estimate the used memory occupied by the data dictionary