[Commits] 08d7bf34b: Add PerfContext::lock_{acquire, release}_count counters
revision-id: 08d7bf34ba792084073a668a22b63f162cc6c0f1 (v5.8-1904-g08d7bf34b) parent(s): 6b3b684f69a5b6ad968f2270e54e92de1a42d468 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2020-04-01 20:41:23 +0300 message: Add PerfContext::lock_{acquire,release}_count counters These are incremented both for point and range locking. --- include/rocksdb/perf_context.h | 3 +++ monitoring/perf_context.cc | 12 ++++++++++++ utilities/transactions/range_locking/locktree/locktree.cc | 3 +++ utilities/transactions/range_locking/locktree/locktree.h | 13 +++++++++++++ utilities/transactions/transaction_lock_mgr.cc | 3 +++ 5 files changed, 34 insertions(+) diff --git a/include/rocksdb/perf_context.h b/include/rocksdb/perf_context.h index a1d803c2c..91f2699ae 100644 --- a/include/rocksdb/perf_context.h +++ b/include/rocksdb/perf_context.h @@ -221,6 +221,9 @@ struct PerfContext { uint64_t iter_prev_cpu_nanos; uint64_t iter_seek_cpu_nanos; + uint64_t lock_acquire_count; + uint64_t lock_release_count; + std::map<uint32_t, PerfContextByLevel>* level_to_perf_context = nullptr; bool per_level_perf_context_enabled = false; }; diff --git a/monitoring/perf_context.cc b/monitoring/perf_context.cc index 5e0d5ac25..78625df0c 100644 --- a/monitoring/perf_context.cc +++ b/monitoring/perf_context.cc @@ -129,6 +129,9 @@ PerfContext::PerfContext(const PerfContext& other) { *level_to_perf_context = *other.level_to_perf_context; } per_level_perf_context_enabled = other.per_level_perf_context_enabled; + + lock_acquire_count = other.lock_acquire_count; + lock_release_count = other.lock_release_count; #endif } @@ -224,6 +227,9 @@ PerfContext::PerfContext(PerfContext&& other) noexcept { other.level_to_perf_context = nullptr; } per_level_perf_context_enabled = other.per_level_perf_context_enabled; + + lock_acquire_count = other.lock_acquire_count; + lock_release_count = other.lock_release_count; #endif } @@ -321,6 +327,9 @@ PerfContext& PerfContext::operator=(const PerfContext& other) { *level_to_perf_context = *other.level_to_perf_context; } per_level_perf_context_enabled = other.per_level_perf_context_enabled; + + lock_acquire_count = other.lock_acquire_count; + lock_release_count = other.lock_release_count; #endif return *this; } @@ -412,6 +421,9 @@ void PerfContext::Reset() { kv.second.Reset(); } } + + lock_acquire_count = 0; + lock_release_count = 0; #endif } diff --git a/utilities/transactions/range_locking/locktree/locktree.cc b/utilities/transactions/range_locking/locktree/locktree.cc index 3c32e1b77..4952fabb9 100644 --- a/utilities/transactions/range_locking/locktree/locktree.cc +++ b/utilities/transactions/range_locking/locktree/locktree.cc @@ -488,6 +488,7 @@ int locktree::acquire_lock(bool is_write_request, // we are only supporting write locks for simplicity //invariant(is_write_request); + PERF_COUNTER_ADD(lock_acquire_count, 1); // acquire and prepare a locked keyrange over the requested range. // prepare is a serialzation point, so we take the opportunity to @@ -634,6 +635,8 @@ void locktree::remove_overlapping_locks_for_txnid(TXNID txnid, keyrange release_range; release_range.create(left_key, right_key); + PERF_COUNTER_ADD(lock_release_count, 1); + // acquire and prepare a locked keyrange over the release range concurrent_tree::locked_keyrange lkr; lkr.prepare(m_rangetree); diff --git a/utilities/transactions/range_locking/locktree/locktree.h b/utilities/transactions/range_locking/locktree/locktree.h index e7c909be0..624e61ec5 100644 --- a/utilities/transactions/range_locking/locktree/locktree.h +++ b/utilities/transactions/range_locking/locktree/locktree.h @@ -67,6 +67,19 @@ struct DICTIONARY_ID { uint64_t dictid; }; +#ifndef ROCKSDB_SUPPORT_THREAD_LOCAL +#error ROCKSDB_SUPPORT_THREAD_LOCALAAAA +#endif + +#include "rocksdb/perf_context.h" +#include "monitoring/perf_level_imp.h" +#include "monitoring/perf_context_imp.h" + +//psergey-new: +using rocksdb::PerfLevel; +using rocksdb::perf_level; +using rocksdb::perf_context; + #include <util/omt.h> #include "txnid_set.h" diff --git a/utilities/transactions/transaction_lock_mgr.cc b/utilities/transactions/transaction_lock_mgr.cc index fa8e49476..6734f03fa 100644 --- a/utilities/transactions/transaction_lock_mgr.cc +++ b/utilities/transactions/transaction_lock_mgr.cc @@ -300,6 +300,8 @@ Status TransactionLockMgr::TryLock(PessimisticTransaction* txn, return Status::InvalidArgument(msg); } + PERF_COUNTER_ADD(lock_acquire_count, 1); + // Need to lock the mutex for the stripe that this key hashes to size_t stripe_num = lock_map->GetStripe(key); assert(lock_map->lock_map_stripes_.size() > stripe_num); @@ -595,6 +597,7 @@ void TransactionLockMgr::UnLockKey(const PessimisticTransaction* txn, #ifdef NDEBUG (void)env; #endif + PERF_COUNTER_ADD(lock_release_count, 1); TransactionID txn_id = txn->GetID(); auto stripe_iter = stripe->keys.find(key);
participants (1)
-
psergey