mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
chore: Introduce LockKey for LockTable (#2463)
This should reduce allocations in a common case (not multi). In addition, rename Transaction::args_ to kv_args_. Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io> Co-authored-by: Vladislav <vlad@dragonflydb.io>
This commit is contained in:
parent
9f4c4353b5
commit
d608ec9c62
8 changed files with 134 additions and 73 deletions
|
@ -167,9 +167,7 @@ class RoundRobinSharder {
|
|||
|
||||
bool HasContendedLocks(unsigned shard_id, Transaction* trx, const DbTable* table) {
|
||||
auto is_contended = [table](string_view key) {
|
||||
auto it = table->trans_locks.find(key);
|
||||
DCHECK(it != table->trans_locks.end());
|
||||
return it->second.IsContended();
|
||||
return table->trans_locks.Find(key)->IsContended();
|
||||
};
|
||||
|
||||
if (trx->IsMulti()) {
|
||||
|
@ -771,13 +769,13 @@ auto EngineShard::AnalyzeTxQueue() const -> TxQueueInfo {
|
|||
if (table == nullptr)
|
||||
continue;
|
||||
|
||||
info.total_locks += table->trans_locks.size();
|
||||
for (const auto& k_v : table->trans_locks) {
|
||||
if (k_v.second.IsContended()) {
|
||||
info.total_locks += table->trans_locks.Size();
|
||||
for (const auto& [key, lock] : table->trans_locks) {
|
||||
if (lock.IsContended()) {
|
||||
info.contended_locks++;
|
||||
if (k_v.second.ContentionScore() > info.max_contention_score) {
|
||||
info.max_contention_score = k_v.second.ContentionScore();
|
||||
info.max_contention_lock_name = k_v.first;
|
||||
if (lock.ContentionScore() > info.max_contention_score) {
|
||||
info.max_contention_score = lock.ContentionScore();
|
||||
info.max_contention_lock_name = string_view{key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue