Skip to content

Commit

Permalink
MDEV-34973: innobase/dict0dict: add noexcept to lock/unlock methods
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MaxKellermann authored and dr-m committed Oct 1, 2024
1 parent 813123e commit 6715e4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions storage/innobase/dict/dict0dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}
Expand Down
24 changes: 12 additions & 12 deletions storage/innobase/include/dict0dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -1493,43 +1493,43 @@ 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));
}

#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
Expand Down

0 comments on commit 6715e4d

Please sign in to comment.