Commit 03f9bb8c authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-28313: Shrink ReadView::m_mutex

A few PERFORMANCE_SCHEMA instrumentation keys were not exposed
in all_innodb_mutexes[]. Let us remove them.

The keys fts_pll_tokenize_mutex_key and read_view_mutex_key were
internally used. Let us make ReadView::m_mutex use the simpler
and smaller srw_mutex, hoping to improve memory access patterns.
parent 8074ab57
...@@ -522,7 +522,6 @@ mysql_pfs_key_t fts_cache_mutex_key; ...@@ -522,7 +522,6 @@ mysql_pfs_key_t fts_cache_mutex_key;
mysql_pfs_key_t fts_cache_init_mutex_key; mysql_pfs_key_t fts_cache_init_mutex_key;
mysql_pfs_key_t fts_delete_mutex_key; mysql_pfs_key_t fts_delete_mutex_key;
mysql_pfs_key_t fts_doc_id_mutex_key; mysql_pfs_key_t fts_doc_id_mutex_key;
mysql_pfs_key_t fts_pll_tokenize_mutex_key;
mysql_pfs_key_t ibuf_bitmap_mutex_key; mysql_pfs_key_t ibuf_bitmap_mutex_key;
mysql_pfs_key_t ibuf_mutex_key; mysql_pfs_key_t ibuf_mutex_key;
mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key; mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
...@@ -544,9 +543,6 @@ mysql_pfs_key_t trx_pool_manager_mutex_key; ...@@ -544,9 +543,6 @@ mysql_pfs_key_t trx_pool_manager_mutex_key;
mysql_pfs_key_t lock_wait_mutex_key; mysql_pfs_key_t lock_wait_mutex_key;
mysql_pfs_key_t trx_sys_mutex_key; mysql_pfs_key_t trx_sys_mutex_key;
mysql_pfs_key_t srv_threads_mutex_key; mysql_pfs_key_t srv_threads_mutex_key;
mysql_pfs_key_t thread_mutex_key;
mysql_pfs_key_t row_drop_list_mutex_key;
mysql_pfs_key_t read_view_mutex_key;
/* all_innodb_mutexes array contains mutexes that are /* all_innodb_mutexes array contains mutexes that are
performance schema instrumented if "UNIV_PFS_MUTEX" performance schema instrumented if "UNIV_PFS_MUTEX"
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, 2021, MariaDB Corporation. Copyright (c) 2018, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -28,12 +28,9 @@ Created 2/16/1997 Heikki Tuuri ...@@ -28,12 +28,9 @@ Created 2/16/1997 Heikki Tuuri
#include "dict0mem.h" #include "dict0mem.h"
#include "trx0types.h" #include "trx0types.h"
#include "srw_lock.h"
#include <algorithm> #include <algorithm>
#ifdef UNIV_PFS_MUTEX
extern mysql_pfs_key_t read_view_mutex_key;
#endif
/** /**
Read view lists the trx ids of those transactions for which a consistent read Read view lists the trx ids of those transactions for which a consistent read
should not see the modifications to the database. should not see the modifications to the database.
...@@ -44,7 +41,7 @@ class ReadViewBase ...@@ -44,7 +41,7 @@ class ReadViewBase
The read should not see any transaction with trx id >= this value. The read should not see any transaction with trx id >= this value.
In other words, this is the "high water mark". In other words, this is the "high water mark".
*/ */
trx_id_t m_low_limit_id; trx_id_t m_low_limit_id= 0;
/** /**
The read should see all trx ids which are strictly The read should see all trx ids which are strictly
...@@ -70,9 +67,6 @@ class ReadViewBase ...@@ -70,9 +67,6 @@ class ReadViewBase
trx_id_t up_limit_id() const { return m_up_limit_id; } trx_id_t up_limit_id() const { return m_up_limit_id; }
public: public:
ReadViewBase(): m_low_limit_id(0) {}
/** /**
Append state from another view. Append state from another view.
...@@ -206,7 +200,7 @@ class ReadView: public ReadViewBase ...@@ -206,7 +200,7 @@ class ReadView: public ReadViewBase
std::atomic<bool> m_open; std::atomic<bool> m_open;
/** For synchronisation with purge coordinator. */ /** For synchronisation with purge coordinator. */
mutable mysql_mutex_t m_mutex; mutable srw_mutex m_mutex;
/** /**
trx id of creating transaction. trx id of creating transaction.
...@@ -215,9 +209,12 @@ class ReadView: public ReadViewBase ...@@ -215,9 +209,12 @@ class ReadView: public ReadViewBase
trx_id_t m_creator_trx_id; trx_id_t m_creator_trx_id;
public: public:
ReadView(): m_open(false) ReadView()
{ mysql_mutex_init(read_view_mutex_key, &m_mutex, nullptr); } {
~ReadView() { mysql_mutex_destroy(&m_mutex); } memset(reinterpret_cast<void*>(this), 0, sizeof *this);
m_mutex.init();
}
~ReadView() { m_mutex.destroy(); }
/** /**
...@@ -265,12 +262,12 @@ class ReadView: public ReadViewBase ...@@ -265,12 +262,12 @@ class ReadView: public ReadViewBase
*/ */
void print_limits(FILE *file) const void print_limits(FILE *file) const
{ {
mysql_mutex_lock(&m_mutex); m_mutex.wr_lock();
if (is_open()) if (is_open())
fprintf(file, "Trx read view will not see trx with" fprintf(file, "Trx read view will not see trx with"
" id >= " TRX_ID_FMT ", sees < " TRX_ID_FMT "\n", " id >= " TRX_ID_FMT ", sees < " TRX_ID_FMT "\n",
low_limit_id(), up_limit_id()); low_limit_id(), up_limit_id());
mysql_mutex_unlock(&m_mutex); m_mutex.wr_unlock();
} }
...@@ -289,10 +286,10 @@ class ReadView: public ReadViewBase ...@@ -289,10 +286,10 @@ class ReadView: public ReadViewBase
*/ */
void append_to(ReadViewBase *to) const void append_to(ReadViewBase *to) const
{ {
mysql_mutex_lock(&m_mutex); m_mutex.wr_lock();
if (is_open()) if (is_open())
to->append(*this); to->append(*this);
mysql_mutex_unlock(&m_mutex); m_mutex.wr_unlock();
} }
/** /**
......
...@@ -540,7 +540,6 @@ extern mysql_pfs_key_t fts_cache_mutex_key; ...@@ -540,7 +540,6 @@ extern mysql_pfs_key_t fts_cache_mutex_key;
extern mysql_pfs_key_t fts_cache_init_mutex_key; extern mysql_pfs_key_t fts_cache_init_mutex_key;
extern mysql_pfs_key_t fts_delete_mutex_key; extern mysql_pfs_key_t fts_delete_mutex_key;
extern mysql_pfs_key_t fts_doc_id_mutex_key; extern mysql_pfs_key_t fts_doc_id_mutex_key;
extern mysql_pfs_key_t fts_pll_tokenize_mutex_key;
extern mysql_pfs_key_t ibuf_bitmap_mutex_key; extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
extern mysql_pfs_key_t ibuf_mutex_key; extern mysql_pfs_key_t ibuf_mutex_key;
extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key; extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
...@@ -561,8 +560,6 @@ extern mysql_pfs_key_t trx_pool_mutex_key; ...@@ -561,8 +560,6 @@ extern mysql_pfs_key_t trx_pool_mutex_key;
extern mysql_pfs_key_t trx_pool_manager_mutex_key; extern mysql_pfs_key_t trx_pool_manager_mutex_key;
extern mysql_pfs_key_t lock_wait_mutex_key; extern mysql_pfs_key_t lock_wait_mutex_key;
extern mysql_pfs_key_t srv_threads_mutex_key; extern mysql_pfs_key_t srv_threads_mutex_key;
extern mysql_pfs_key_t thread_mutex_key;
extern mysql_pfs_key_t row_drop_list_mutex_key;
# endif /* UNIV_PFS_MUTEX */ # endif /* UNIV_PFS_MUTEX */
# ifdef UNIV_PFS_RWLOCK # ifdef UNIV_PFS_RWLOCK
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, 2021, MariaDB Corporation. Copyright (c) 2018, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -226,10 +226,10 @@ void ReadView::open(trx_t *trx) ...@@ -226,10 +226,10 @@ void ReadView::open(trx_t *trx)
m_open.store(true, std::memory_order_relaxed); m_open.store(true, std::memory_order_relaxed);
else else
{ {
mysql_mutex_lock(&m_mutex); m_mutex.wr_lock();
snapshot(trx); snapshot(trx);
m_open.store(true, std::memory_order_relaxed); m_open.store(true, std::memory_order_relaxed);
mysql_mutex_unlock(&m_mutex); m_mutex.wr_unlock();
} }
} }
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2021, MariaDB Corporation. Copyright (c) 2015, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -285,8 +285,7 @@ row_fts_psort_info_init( ...@@ -285,8 +285,7 @@ row_fts_psort_info_init(
psort_info[j].psort_common = common_info; psort_info[j].psort_common = common_info;
psort_info[j].error = DB_SUCCESS; psort_info[j].error = DB_SUCCESS;
psort_info[j].memory_used = 0; psort_info[j].memory_used = 0;
mysql_mutex_init(fts_pll_tokenize_mutex_key, mysql_mutex_init(0, &psort_info[j].mutex, nullptr);
&psort_info[j].mutex, nullptr);
} }
/* Initialize merge_info structures parallel merge and insert /* Initialize merge_info structures parallel merge and insert
......
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