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
This commit is contained in:
Max Kellermann 2024-09-20 10:34:44 +02:00 committed by Marko Mäkelä
parent 813123e3e0
commit 6715e4dfe1
2 changed files with 16 additions and 16 deletions

View file

@ -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();
}

View file

@ -1493,24 +1493,24 @@ public:
#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 @@ public:
#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