mariadb/storage/innobase/row
Marko Mäkelä acd071f599 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
2025-04-10 13:02:17 +03:00
..
row0ext.cc Merge 10.3 into 10.4 2020-07-02 07:39:33 +03:00
row0ftsort.cc Merge branch '10.6' into 10.11 2023-12-18 11:19:04 +01:00
row0import.cc MDEV-35169 ALTER TABLE...IMPORT TABLESPACE does not work with INDEX DESC 2025-01-28 11:56:35 +05:30
row0ins.cc Merge fixup 2025-04-02 09:33:09 +03:00
row0log.cc Merge 10.6 into 10.11 2025-03-27 08:01:47 +02:00
row0merge.cc MDEV-34703 LOAD DATA INFILE using Innodb bulk load aborts 2025-01-15 23:49:13 +05:30
row0mysql.cc MDEV-21923: LSN allocation is a bottleneck 2025-04-10 13:02:17 +03:00
row0purge.cc MDEV-35000 preparation: Clean up dict_table_t::stat 2025-02-28 08:55:16 +02:00
row0quiesce.cc MDEV-35169 ALTER TABLE...IMPORT TABLESPACE does not work with INDEX DESC 2025-01-28 11:56:35 +05:30
row0row.cc Merge branch '10.5' into 10.6 2024-10-29 14:20:03 +01:00
row0sel.cc Merge 10.6 into 10.11 2025-02-25 10:23:24 +02:00
row0uins.cc MDEV-35000: dict_table_close() breaks STATS_AUTO_RECALC 2025-02-28 09:00:16 +02:00
row0umod.cc MDEV-35000: dict_table_close() breaks STATS_AUTO_RECALC 2025-02-28 09:00:16 +02:00
row0undo.cc MDEV-32175: Reduce page_align(), page_offset() calls 2024-11-21 11:01:30 +02:00
row0upd.cc MDEV-35000: dict_table_close() breaks STATS_AUTO_RECALC 2025-02-28 09:00:16 +02:00
row0vers.cc Merge 10.6 into 10.11 2024-11-29 13:43:17 +02:00