mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
opt(lua): Avoid separate hops for lock & unlock on single shard execution (#1900)
This commit is contained in:
parent
8cc448f6b4
commit
2091f53777
5 changed files with 78 additions and 44 deletions
|
@ -54,7 +54,12 @@ Transaction::Transaction(const CommandId* cid) : cid_{cid} {
|
|||
|
||||
Transaction::Transaction(const Transaction* parent)
|
||||
: multi_{make_unique<MultiData>()}, txid_{parent->txid()} {
|
||||
multi_->mode = parent->multi_->mode;
|
||||
if (parent->multi_) {
|
||||
multi_->mode = parent->multi_->mode;
|
||||
} else {
|
||||
// Use squashing mechanism for inline execution of single-shard EVAL
|
||||
multi_->mode = LOCK_AHEAD;
|
||||
}
|
||||
multi_->role = SQUASHED_STUB;
|
||||
|
||||
time_now_ms_ = parent->time_now_ms_;
|
||||
|
@ -405,6 +410,15 @@ string Transaction::DebugId() const {
|
|||
return StrCat(Name(), "@", txid_, "/", unique_shard_cnt_, " (", trans_id(this), ")");
|
||||
}
|
||||
|
||||
void Transaction::PrepareMultiForScheduleSingleHop(ShardId sid, DbIndex db, CmdArgList args) {
|
||||
multi_.reset();
|
||||
InitBase(db, args);
|
||||
EnableShard(sid);
|
||||
OpResult<KeyIndex> key_index = DetermineKeys(cid_, args);
|
||||
CHECK(key_index);
|
||||
StoreKeysInArgs(*key_index, false);
|
||||
}
|
||||
|
||||
// Runs in the dbslice thread. Returns true if the transaction continues running in the thread.
|
||||
bool Transaction::RunInShard(EngineShard* shard, bool txq_ooo) {
|
||||
DCHECK_GT(run_count_.load(memory_order_relaxed), 0u);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue