summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2019-12-11 23:32:50 +0700
committerEugene Kosov <claprix@yandex.ru>2019-12-11 23:32:50 +0700
commitf4b4284650cc787b8e4c9d4515dca1917cb138b5 (patch)
treeb84d343d3508447e1e439cab5a34ef8669ad3180
parentadb117cf6901a0e0da7577267be1209359892207 (diff)
downloadmariadb-git-f4b4284650cc787b8e4c9d4515dca1917cb138b5.tar.gz
MDEV-16678 Prefer MDL to dict_sys.latch for innodb background tasks
Use std::queue backed by std::deque instead of list because it does less allocations which still having O(1) push and pop operations. Also store trx_purge_rec_t directly, because its only 16 bytes and allocating it is to wasteful. This should be faster. purge_node_t::purge_node_t: container is already empty after creation purge_node_t::end(): replace clearing container with assertion that it's clear
-rw-r--r--storage/innobase/include/row0purge.h7
-rw-r--r--storage/innobase/row/row0purge.cc9
-rw-r--r--storage/innobase/trx/trx0purge.cc17
3 files changed, 14 insertions, 19 deletions
diff --git a/storage/innobase/include/row0purge.h b/storage/innobase/include/row0purge.h
index 93682f7738c..091d80adec5 100644
--- a/storage/innobase/include/row0purge.h
+++ b/storage/innobase/include/row0purge.h
@@ -34,7 +34,7 @@ Created 3/14/1997 Heikki Tuuri
#include "row0types.h"
#include "row0mysql.h"
#include "mysqld.h"
-#include <list>
+#include <queue>
class MDL_ticket;
/** Determines if it is possible to remove a secondary index entry.
@@ -150,7 +150,7 @@ public:
int mdl_hold_recs;
/** Undo recs to purge */
- std::list<trx_purge_rec_t*> undo_recs;
+ std::queue<trx_purge_rec_t> undo_recs;
/** Constructor */
explicit purge_node_t(que_thr_t* parent) :
@@ -166,7 +166,6 @@ public:
purge_thd(NULL),
mdl_hold_recs(0)
{
- undo_recs.clear();
}
#ifdef UNIV_DEBUG
@@ -258,7 +257,7 @@ public:
{
DBUG_ASSERT(common.type == QUE_NODE_PURGE);
close_table();
- undo_recs.clear();
+ ut_ad(undo_recs.empty());
ut_d(in_progress= false);
purge_thd= nullptr;
mem_heap_empty(heap);
diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc
index d5b9cb386f2..def990a462c 100644
--- a/storage/innobase/row/row0purge.cc
+++ b/storage/innobase/row/row0purge.cc
@@ -1155,12 +1155,11 @@ row_purge_step(
node->start();
if (!node->undo_recs.empty()) {
- trx_purge_rec_t* purge_rec =
- node->undo_recs.front();
- node->undo_recs.pop_front();
- node->roll_ptr = purge_rec->roll_ptr;
+ trx_purge_rec_t purge_rec = node->undo_recs.front();
+ node->undo_recs.pop();
+ node->roll_ptr = purge_rec.roll_ptr;
- row_purge(node, purge_rec->undo_rec, thr);
+ row_purge(node, purge_rec.undo_rec, thr);
if (node->undo_recs.empty()) {
row_purge_end(thr);
diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc
index 6ab2c57056c..0dce72eba87 100644
--- a/storage/innobase/trx/trx0purge.cc
+++ b/storage/innobase/trx/trx0purge.cc
@@ -1141,7 +1141,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) {
purge_node_t* node;
- trx_purge_rec_t* purge_rec;
+ trx_purge_rec_t purge_rec;
ut_a(!thr->is_active);
@@ -1149,9 +1149,6 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
node = (purge_node_t*) thr->child;
ut_a(que_node_get_type(node) == QUE_NODE_PURGE);
- purge_rec = static_cast<trx_purge_rec_t*>(
- mem_heap_zalloc(purge_sys.heap, sizeof(*purge_rec)));
-
/* Track the max {trx_id, undo_no} for truncating the
UNDO logs once we have purged the records. */
@@ -1160,18 +1157,18 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
}
/* Fetch the next record, and advance the purge_sys.tail. */
- purge_rec->undo_rec = trx_purge_fetch_next_rec(
- &purge_rec->roll_ptr, &n_pages_handled,
+ purge_rec.undo_rec = trx_purge_fetch_next_rec(
+ &purge_rec.roll_ptr, &n_pages_handled,
purge_sys.heap);
- if (purge_rec->undo_rec == NULL) {
+ if (purge_rec.undo_rec == NULL) {
break;
- } else if (purge_rec->undo_rec == &trx_purge_dummy_rec) {
+ } else if (purge_rec.undo_rec == &trx_purge_dummy_rec) {
continue;
}
table_id_t table_id = trx_undo_rec_get_table_id(
- purge_rec->undo_rec);
+ purge_rec.undo_rec);
auto it = table_id_map.find(table_id);
@@ -1189,7 +1186,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
table_id_map.insert({table_id, node});
}
- node->undo_recs.push_back(purge_rec);
+ node->undo_recs.push(purge_rec);
if (n_pages_handled >= batch_size) {
break;