From 03b2c841f43d95ec8bb98b3c17cd60e3dca6de81 Mon Sep 17 00:00:00 2001 From: sfu2 Date: Fri, 23 Jan 2026 09:20:23 +0000 Subject: [PATCH 1/3] Avoid redundant Datafile copy (NFC) --- storage/innobase/fsp/fsp0space.cc | 2 +- storage/innobase/fsp/fsp0sysspace.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc index cf546ec687284..784f5c8859eac 100644 --- a/storage/innobase/fsp/fsp0space.cc +++ b/storage/innobase/fsp/fsp0space.cc @@ -210,7 +210,7 @@ dberr_t Tablespace::add_datafile(const char *filepath) /* Now add a new Datafile and set the filepath using the m_path created above. */ - m_files.push_back(Datafile(m_flags, FIL_IBD_FILE_INITIAL_SIZE, 0)); + m_files.emplace_back(m_flags, FIL_IBD_FILE_INITIAL_SIZE, 0); m_files.back().make_filepath(m_path, {basename, strlen(basename) - 4}, IBD); diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc index 4f7ebaa3d559d..e9d7be9f7a8e3 100644 --- a/storage/innobase/fsp/fsp0sysspace.cc +++ b/storage/innobase/fsp/fsp0sysspace.cc @@ -288,7 +288,7 @@ SysTablespace::parse_params( } } - m_files.push_back(Datafile(flags(), uint32_t(size), order)); + m_files.emplace_back(flags(), uint32_t(size), order); m_files.back().make_filepath(path(), {filepath, strlen(filepath)}, NO_EXT); From e0da8884eb3ed561b6dd1d126a91b31c439b63c3 Mon Sep 17 00:00:00 2001 From: sfu2 Date: Fri, 23 Jan 2026 09:20:23 +0000 Subject: [PATCH 2/3] Avoid map copy in for loop (NFC) --- storage/innobase/trx/trx0purge.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 9ba4a8f3e190f..191389071153f 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1326,7 +1326,7 @@ void purge_sys_t::batch_cleanup(const purge_sys_t::iterator &head) m_active= false; /* Release the undo pages. */ - for (auto p : pages) + for (auto &p : pages) p.second->unfix(); pages.clear(); pages.reserve(srv_purge_batch_size); From c890f170c9ad9255f260c5a2a03f57685c71978c Mon Sep 17 00:00:00 2001 From: sfu2 Date: Fri, 23 Jan 2026 09:20:23 +0000 Subject: [PATCH 3/3] Faster resize for tpool::circular_queue (NFC) --- tpool/tpool_structs.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tpool/tpool_structs.h b/tpool/tpool_structs.h index 8077651de1c1b..6da933319aeb7 100644 --- a/tpool/tpool_structs.h +++ b/tpool/tpool_structs.h @@ -245,19 +245,16 @@ template class circular_queue if (new_size <= current_size) return; size_t new_capacity = new_size - 1; - std::vector new_buffer(new_capacity); - /* Figure out faster way to copy*/ - size_t i = 0; - while (!empty()) + size_t const old_size = m_buffer.size(); + m_buffer.resize(new_capacity); + if (m_head < m_tail) { - T& ele = front(); - pop(); - new_buffer[i++] = ele; - } - m_buffer = new_buffer; + for (size_t i = new_capacity - 1, j = old_size - 1; m_tail <= j; --i, --j) + std::swap(m_buffer[i], m_buffer[j]); + m_tail = m_tail + (m_buffer.size() - old_size); + } m_capacity = new_capacity; - m_tail = 0; - m_head = current_size; + assert(size() == current_size); } void push(T ele) {