mariadb/storage/innobase/row
Marko Mäkelä d41b488495 MDEV-21923: LSN allocation is a bottleneck
The parameter innodb_log_spin_wait_delay will be deprecated and
ignored, because there is no spin loop anymore.

Thanks to commit 685d958e38
and commit a635c40648
multiple mtr_t::commit() can concurrently copy their slice of
mtr_t::m_log to the shared log_sys.buf.  Each writer would allocate
their own log sequence number by invoking log_t::append_prepare()
while holding a shared log_sys.latch.  This function was too heavy,
because it would invoke a minimum of 4 atomic read-modify-write
operations as well as system calls in the supposedly fast code path.

It turns out that with a simpler data structure, instead of having
several data fields that needed to be kept consistent with each other,
we only need one Atomic_relaxed<uint64_t> write_lsn_offset, on which
we can operate using fetch_add(), fetch_sub() as well as a single-bit
fetch_or(), which reasonably modern compilers (GCC 7, Clang 15 or later)
can translate into loop-free code on AMD64.

Before anything can be written to the log, log_sys.clear_mmap()
must be invoked.

log_t::base_lsn: The LSN of the last write_buf() or persist().
This is a rough approximation of log_sys.lsn, which will be removed.

log_t::write_lsn_offset: An Atomic_relaxed<uint64_t> that buffers
updates of write_to_buf and base_lsn.

log_t::buf_free, log_t::max_buf_free, log_t::lsn. Remove.
Replaced by base_lsn and write_lsn_offset.

log_t::buf_size: Always reflects the usable size in append_prepare().

log_t::lsn_lock: Remove.  For the memory-mapped log in resize_write(),
there will be a resize_wrap_mutex.

log_t::get_lsn_approx(): Return a lower bound of get_lsn().
This should be exact unless append_prepare_wait() is pending.

log_get_lsn(): A wrapper for log_sys.get_lsn(), which must be invoked
while holding an exclusive log_sys.latch.

recv_recovery_from_checkpoint_start(): Do not invoke fil_names_clear();
it would seem to be unnecessary.

In many places, references to log_sys.get_lsn() are replaced with
log_sys.get_flushed_lsn(), which remains a simple std::atomic::load().

Reviewed by: Debarun Banerjee

(cherry picked from commit acd071f599)
2025-05-22 09:40:30 +03:00
..
row0ext.cc Merge 10.3 into 10.4 2020-07-02 07:39:33 +03:00
row0ftsort.cc Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00
row0import.cc Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00
row0ins.cc Merge branch '11.8' into main 2025-04-18 17:11:01 +02:00
row0log.cc Merge 11.4 into 11.8 2025-04-02 14:07:01 +03:00
row0merge.cc Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00
row0mysql.cc MDEV-21923: LSN allocation is a bottleneck 2025-05-22 09:40:30 +03:00
row0purge.cc Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00
row0quiesce.cc Merge branch '11.4' into 11.7 2025-02-06 16:46:36 +01:00
row0row.cc MDEV-35049: Use CRC-32C and avoid allocating heap 2025-01-10 16:39:44 +02:00
row0sel.cc Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00
row0uins.cc Merge 10.11 into 11.4 2025-03-03 11:07:56 +02:00
row0umod.cc Merge 10.11 into 11.4 2025-03-03 11:07:56 +02:00
row0undo.cc MDEV-32175: Reduce page_align(), page_offset() calls 2024-11-21 11:01:30 +02:00
row0upd.cc Merge 10.11 into 11.4 2025-03-03 11:07:56 +02:00
row0vers.cc Fix typos in C comments inside storage/ 2025-03-26 16:56:50 +04:00