mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 09:55:45 +02:00
chore: LockTable tracks fingerprints of keys (#2839)
* chore: LockTable tracks fingerprints of keys It's a first step that will probably simplify dependencies in many places where we need to keep key strings for that. A second step will be to reduce the CPU load of multi-key operations like MSET and precompute Fingerprints once. --------- Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
56a7f85e39
commit
da5c51d1dd
11 changed files with 59 additions and 57 deletions
|
@ -51,7 +51,7 @@ void AnalyzeTxQueue(const EngineShard* shard, const TxQueue* txq) {
|
|||
", runnable:", info.tx_runnable, ", total locks: ", info.total_locks,
|
||||
", contended locks: ", info.contended_locks, "\n");
|
||||
absl::StrAppend(&msg, "max contention score: ", info.max_contention_score,
|
||||
", lock: ", info.max_contention_lock_name,
|
||||
", lock: ", info.max_contention_lock,
|
||||
", poll_executions:", shard->stats().poll_execution_total);
|
||||
const Transaction* cont_tx = shard->GetContTx();
|
||||
if (cont_tx) {
|
||||
|
@ -82,6 +82,15 @@ uint16_t trans_id(const Transaction* ptr) {
|
|||
return (intptr_t(ptr) >> 8) & 0xFFFF;
|
||||
}
|
||||
|
||||
bool CheckLocks(const DbSlice& db_slice, IntentLock::Mode mode, const KeyLockArgs& lock_args) {
|
||||
for (size_t i = 0; i < lock_args.args.size(); i += lock_args.key_step) {
|
||||
string_view s = KeyLockArgs::GetLockKey(lock_args.args[i]);
|
||||
if (!db_slice.CheckLock(mode, lock_args.db_index, s))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool Transaction::BatonBarrier::IsClaimed() const {
|
||||
|
@ -1076,7 +1085,7 @@ bool Transaction::ScheduleInShard(EngineShard* shard, bool can_run_immediately)
|
|||
bool shard_unlocked = shard->shard_lock()->Check(mode);
|
||||
|
||||
// Check if we can run immediately
|
||||
if (shard_unlocked && can_run_immediately && shard->db_slice().CheckLock(mode, lock_args)) {
|
||||
if (shard_unlocked && can_run_immediately && CheckLocks(shard->db_slice(), mode, lock_args)) {
|
||||
sd.local_mask |= RAN_IMMEDIATELY;
|
||||
shard->stats().tx_immediate_total++;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue