From 8295d364e2350574f58e18e2096fdee52a833e69 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Mon, 15 Apr 2019 10:30:48 -0700 Subject: [PATCH] Improve transaction lock details (#5193) Summary: This branch contains two small improvements: * Create `LockMap` entries using `std::make_shared`. This saves one heap allocation per LockMap entry but also locates the control block and the LockMap object closely together in memory, which can help with caching * Reorder the members of `TrackedTrxInfo`, so that the resulting struct uses less memory (at least on 64bit systems) Pull Request resolved: https://github.com/facebook/rocksdb/pull/5193 Differential Revision: D14934536 Pulled By: maysamyabandeh fbshipit-source-id: f7b49812bb4b6029eef9d131e7cd56260df5b28e --- utilities/transactions/transaction_lock_mgr.cc | 5 ++--- utilities/transactions/transaction_lock_mgr.h | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/utilities/transactions/transaction_lock_mgr.cc b/utilities/transactions/transaction_lock_mgr.cc index 43f62bafb..48d496bfd 100644 --- a/utilities/transactions/transaction_lock_mgr.cc +++ b/utilities/transactions/transaction_lock_mgr.cc @@ -192,8 +192,7 @@ void TransactionLockMgr::AddColumnFamily(uint32_t column_family_id) { if (lock_maps_.find(column_family_id) == lock_maps_.end()) { lock_maps_.emplace(column_family_id, - std::shared_ptr( - new LockMap(default_num_stripes_, mutex_factory_))); + std::make_shared(default_num_stripes_, mutex_factory_)); } else { // column_family already exists in lock map assert(false); @@ -450,7 +449,7 @@ bool TransactionLockMgr::IncrementWaiters( std::lock_guard lock(wait_txn_map_mutex_); assert(!wait_txn_map_.Contains(id)); - wait_txn_map_.Insert(id, {wait_ids, cf_id, key, exclusive}); + wait_txn_map_.Insert(id, {wait_ids, cf_id, exclusive, key}); for (auto wait_id : wait_ids) { if (rev_wait_txn_map_.Contains(wait_id)) { diff --git a/utilities/transactions/transaction_lock_mgr.h b/utilities/transactions/transaction_lock_mgr.h index b18271237..b12357604 100644 --- a/utilities/transactions/transaction_lock_mgr.h +++ b/utilities/transactions/transaction_lock_mgr.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -44,8 +45,8 @@ struct DeadlockInfoBuffer { struct TrackedTrxInfo { autovector m_neighbors; uint32_t m_cf_id; - std::string m_waiting_key; bool m_exclusive; + std::string m_waiting_key; }; class Slice;