Commit f4b42846 authored by Eugene Kosov's avatar Eugene Kosov

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
parent adb117cf
...@@ -34,7 +34,7 @@ Created 3/14/1997 Heikki Tuuri ...@@ -34,7 +34,7 @@ Created 3/14/1997 Heikki Tuuri
#include "row0types.h" #include "row0types.h"
#include "row0mysql.h" #include "row0mysql.h"
#include "mysqld.h" #include "mysqld.h"
#include <list> #include <queue>
class MDL_ticket; class MDL_ticket;
/** Determines if it is possible to remove a secondary index entry. /** Determines if it is possible to remove a secondary index entry.
...@@ -150,7 +150,7 @@ struct purge_node_t{ ...@@ -150,7 +150,7 @@ struct purge_node_t{
int mdl_hold_recs; int mdl_hold_recs;
/** Undo recs to purge */ /** Undo recs to purge */
std::list<trx_purge_rec_t*> undo_recs; std::queue<trx_purge_rec_t> undo_recs;
/** Constructor */ /** Constructor */
explicit purge_node_t(que_thr_t* parent) : explicit purge_node_t(que_thr_t* parent) :
...@@ -166,7 +166,6 @@ struct purge_node_t{ ...@@ -166,7 +166,6 @@ struct purge_node_t{
purge_thd(NULL), purge_thd(NULL),
mdl_hold_recs(0) mdl_hold_recs(0)
{ {
undo_recs.clear();
} }
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -258,7 +257,7 @@ struct purge_node_t{ ...@@ -258,7 +257,7 @@ struct purge_node_t{
{ {
DBUG_ASSERT(common.type == QUE_NODE_PURGE); DBUG_ASSERT(common.type == QUE_NODE_PURGE);
close_table(); close_table();
undo_recs.clear(); ut_ad(undo_recs.empty());
ut_d(in_progress= false); ut_d(in_progress= false);
purge_thd= nullptr; purge_thd= nullptr;
mem_heap_empty(heap); mem_heap_empty(heap);
......
...@@ -1155,12 +1155,11 @@ row_purge_step( ...@@ -1155,12 +1155,11 @@ row_purge_step(
node->start(); node->start();
if (!node->undo_recs.empty()) { if (!node->undo_recs.empty()) {
trx_purge_rec_t* purge_rec = trx_purge_rec_t purge_rec = node->undo_recs.front();
node->undo_recs.front(); node->undo_recs.pop();
node->undo_recs.pop_front(); node->roll_ptr = purge_rec.roll_ptr;
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()) { if (node->undo_recs.empty()) {
row_purge_end(thr); row_purge_end(thr);
......
...@@ -1141,7 +1141,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1141,7 +1141,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) { while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) {
purge_node_t* node; purge_node_t* node;
trx_purge_rec_t* purge_rec; trx_purge_rec_t purge_rec;
ut_a(!thr->is_active); ut_a(!thr->is_active);
...@@ -1149,9 +1149,6 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1149,9 +1149,6 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
node = (purge_node_t*) thr->child; node = (purge_node_t*) thr->child;
ut_a(que_node_get_type(node) == QUE_NODE_PURGE); 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 /* Track the max {trx_id, undo_no} for truncating the
UNDO logs once we have purged the records. */ UNDO logs once we have purged the records. */
...@@ -1160,18 +1157,18 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1160,18 +1157,18 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
} }
/* Fetch the next record, and advance the purge_sys.tail. */ /* Fetch the next record, and advance the purge_sys.tail. */
purge_rec->undo_rec = trx_purge_fetch_next_rec( purge_rec.undo_rec = trx_purge_fetch_next_rec(
&purge_rec->roll_ptr, &n_pages_handled, &purge_rec.roll_ptr, &n_pages_handled,
purge_sys.heap); purge_sys.heap);
if (purge_rec->undo_rec == NULL) { if (purge_rec.undo_rec == NULL) {
break; break;
} else if (purge_rec->undo_rec == &trx_purge_dummy_rec) { } else if (purge_rec.undo_rec == &trx_purge_dummy_rec) {
continue; continue;
} }
table_id_t table_id = trx_undo_rec_get_table_id( 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); auto it = table_id_map.find(table_id);
...@@ -1189,7 +1186,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads) ...@@ -1189,7 +1186,7 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
table_id_map.insert({table_id, node}); 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) { if (n_pages_handled >= batch_size) {
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment