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
This commit is contained in:
jsteemann 2019-04-15 10:30:48 -07:00 committed by Facebook Github Bot
parent 29111e92b4
commit 8295d364e2
2 changed files with 4 additions and 4 deletions

View File

@ -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<LockMap>(
new LockMap(default_num_stripes_, mutex_factory_)));
std::make_shared<LockMap>(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<std::mutex> 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)) {

View File

@ -9,6 +9,7 @@
#include <chrono>
#include <string>
#include <unordered_map>
#include <memory>
#include <utility>
#include <vector>
@ -44,8 +45,8 @@ struct DeadlockInfoBuffer {
struct TrackedTrxInfo {
autovector<TransactionID> m_neighbors;
uint32_t m_cf_id;
std::string m_waiting_key;
bool m_exclusive;
std::string m_waiting_key;
};
class Slice;