From 14be81438098923e95bda6d635d638991e60116b Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 18 Oct 2018 18:23:12 +0300 Subject: MDEV-17491 micro optimize page_id_t page_id_t: remove m_fold member various places: pass page_id_t by value instead of by reference --- storage/innobase/include/trx0sys.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'storage/innobase/include/trx0sys.h') diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index ebe70a1c70e..e1bc4850a61 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -57,10 +57,7 @@ extern trx_sys_t* trx_sys; /** Checks if a page address is the trx sys header page. @param[in] page_id page id @return true if trx sys header page */ -UNIV_INLINE -bool -trx_sys_hdr_page( - const page_id_t& page_id); +inline bool trx_sys_hdr_page(const page_id_t page_id); /** Initialize the transaction system main-memory data structures. */ void trx_sys_init_at_db_start(); -- cgit v1.2.1 From 447e4931795a0ae9525005e8fb37bb7347d8ae52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 29 Nov 2018 12:53:44 +0200 Subject: Remove some unnecessary InnoDB #include --- storage/innobase/include/trx0sys.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'storage/innobase/include/trx0sys.h') diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index e1bc4850a61..519ef835fba 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -27,8 +27,6 @@ Created 3/26/1996 Heikki Tuuri #ifndef trx0sys_h #define trx0sys_h -#include "univ.i" - #include "buf0buf.h" #include "fil0fil.h" #include "trx0types.h" -- cgit v1.2.1 From 90377b8028e0103f967d81fd0cbb8ede99d8215a Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 19 Sep 2018 20:51:35 +0400 Subject: MDEV-17441 - InnoDB transition to C++11 atomics trx_sys_t::m_max_trx_id transition to Atomic_counter. Since C++11 doesn't seem to allow mixed (atomic and non-atomic) access to atomic variables, we have to perform atomic initialisation. --- storage/innobase/include/trx0sys.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'storage/innobase/include/trx0sys.h') diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index 8c5be47fb85..fb2b6e4de5c 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -790,7 +790,7 @@ class trx_sys_t The smallest number not yet assigned as a transaction id or transaction number. Accessed and updated with atomic operations. */ - MY_ALIGNED(CACHE_LINE_SIZE) trx_id_t m_max_trx_id; + MY_ALIGNED(CACHE_LINE_SIZE) Atomic_counter m_max_trx_id; /** @@ -887,9 +887,7 @@ public: trx_id_t get_max_trx_id() { - return static_cast - (my_atomic_load64_explicit(reinterpret_cast(&m_max_trx_id), - MY_MEMORY_ORDER_RELAXED)); + return m_max_trx_id; } @@ -1195,8 +1193,7 @@ private: trx_id_t get_new_trx_id_no_refresh() { - return static_cast(my_atomic_add64_explicit( - reinterpret_cast(&m_max_trx_id), 1, MY_MEMORY_ORDER_RELAXED)); + return m_max_trx_id++; } }; -- cgit v1.2.1 From 8023fc6d453aebb2554289d4ed2ab595093a0f14 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 19 Sep 2018 20:55:50 +0400 Subject: MDEV-17441 - InnoDB transition to C++11 atomics Almost trivial trx_sys_t::m_rw_trx_hash_version transition. Since C++11 doesn't seem to allow mixed (atomic and non-atomic) access to atomic variables, we have to perform atomic initialisation. --- storage/innobase/include/trx0sys.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'storage/innobase/include/trx0sys.h') diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index fb2b6e4de5c..fd47832c2e1 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -801,7 +801,7 @@ class trx_sys_t @sa assign_new_trx_no() @sa snapshot_ids() */ - MY_ALIGNED(CACHE_LINE_SIZE) trx_id_t m_rw_trx_hash_version; + MY_ALIGNED(CACHE_LINE_SIZE) std::atomic m_rw_trx_hash_version; /** @@ -982,7 +982,8 @@ public: /** Initialiser for m_max_trx_id and m_rw_trx_hash_version. */ void init_max_trx_id(trx_id_t value) { - m_max_trx_id= m_rw_trx_hash_version= value; + m_max_trx_id= value; + m_rw_trx_hash_version.store(value, std::memory_order_relaxed); } @@ -1163,18 +1164,14 @@ private: /** Getter for m_rw_trx_hash_version, must issue ACQUIRE memory barrier. */ trx_id_t get_rw_trx_hash_version() { - return static_cast - (my_atomic_load64_explicit(reinterpret_cast - (&m_rw_trx_hash_version), - MY_MEMORY_ORDER_ACQUIRE)); + return m_rw_trx_hash_version.load(std::memory_order_acquire); } /** Increments m_rw_trx_hash_version, must issue RELEASE memory barrier. */ void refresh_rw_trx_hash_version() { - my_atomic_add64_explicit(reinterpret_cast(&m_rw_trx_hash_version), - 1, MY_MEMORY_ORDER_RELEASE); + m_rw_trx_hash_version.fetch_add(1, std::memory_order_release); } -- cgit v1.2.1 From 4abdd798f75e345f8692118634c464073de2cda5 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 19 Sep 2018 21:01:57 +0400 Subject: MDEV-17441 - InnoDB transition to C++11 atomics rw_trx_hash_element_t::no transition to Atomic_counter. Since C++11 doesn't seem to allow mixed (atomic and non-atomic) access to atomic variables, we have to perform atomic initialisation. --- storage/innobase/include/trx0sys.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'storage/innobase/include/trx0sys.h') diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index fd47832c2e1..b7c75abde78 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -369,7 +369,7 @@ struct rw_trx_hash_element_t trx_id_t id; /* lf_hash_init() relies on this to be first in the struct */ - trx_id_t no; + Atomic_counter no; trx_t *trx; ib_mutex_t mutex; }; @@ -929,9 +929,7 @@ public: void assign_new_trx_no(trx_t *trx) { trx->no= get_new_trx_id_no_refresh(); - my_atomic_store64_explicit(reinterpret_cast - (&trx->rw_trx_hash_element->no), - trx->no, MY_MEMORY_ORDER_RELAXED); + trx->rw_trx_hash_element->no= trx->no; refresh_rw_trx_hash_version(); } @@ -1151,8 +1149,7 @@ private: { if (element->id < arg->m_id) { - trx_id_t no= static_cast(my_atomic_load64_explicit( - reinterpret_cast(&element->no), MY_MEMORY_ORDER_RELAXED)); + trx_id_t no= element->no; arg->m_ids->push_back(element->id); if (no < arg->m_no) arg->m_no= no; -- cgit v1.2.1 From edde1f6e0d5f5a0115a5253c9b8d428af132f2d1 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Thu, 25 Oct 2018 17:37:16 +0400 Subject: MDEV-17441 - InnoDB transition to C++11 atomics trx_sys_t::rseg_history_len transition to Atomic_counter. --- storage/innobase/include/trx0sys.h | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'storage/innobase/include/trx0sys.h') diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index b7c75abde78..e73cbb81c32 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -804,14 +804,14 @@ class trx_sys_t MY_ALIGNED(CACHE_LINE_SIZE) std::atomic m_rw_trx_hash_version; + bool m_initialised; + +public: /** TRX_RSEG_HISTORY list length (number of committed transactions to purge) */ - MY_ALIGNED(CACHE_LINE_SIZE) int32 rseg_history_len; + MY_ALIGNED(CACHE_LINE_SIZE) Atomic_counter rseg_history_len; - bool m_initialised; - -public: /** Mutex protecting trx_list. */ MY_ALIGNED(CACHE_LINE_SIZE) mutable TrxSysMutex mutex; @@ -1103,22 +1103,6 @@ public: return count; } - /** @return number of committed transactions waiting for purge */ - ulint history_size() const - { - return uint32(my_atomic_load32(&const_cast(this) - ->rseg_history_len)); - } - /** Add to the TRX_RSEG_HISTORY length (on database startup). */ - void history_add(int32 len) - { - my_atomic_add32(&rseg_history_len, len); - } - /** Register a committed transaction. */ - void history_insert() { history_add(1); } - /** Note that a committed transaction was purged. */ - void history_remove() { history_add(-1); } - private: static my_bool get_min_trx_id_callback(rw_trx_hash_element_t *element, trx_id_t *id) -- cgit v1.2.1 From dc90234bda3e2074179a3e54c09a7c9694e69965 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 28 Dec 2018 01:47:17 +0400 Subject: MDEV-17441 - InnoDB transition to C++11 atomics Added lf_hash_size() macro, so that callers don't need to use atomic operations. --- storage/innobase/include/trx0sys.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'storage/innobase/include/trx0sys.h') diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index e73cbb81c32..92f24d036ae 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -704,11 +704,7 @@ public: because it may change even before this method returns. */ - uint32_t size() - { - return uint32_t(my_atomic_load32_explicit(&hash.count, - MY_MEMORY_ORDER_RELAXED)); - } + uint32_t size() { return uint32_t(lf_hash_size(&hash)); } /** -- cgit v1.2.1