Skip to content

Commit

Permalink
feat: run tx-schedule inline if the dest shard is on the same thread (#…
Browse files Browse the repository at this point in the history
…908)

The optimization is applied within ScheduleSingleHop call.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
  • Loading branch information
romange authored Mar 6, 2023
1 parent 64e10f0 commit 5f92f84
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
ninja src/all
ccache --show-stats
echo Run ctest -V -L DFLY
#GLOG_logtostderr=1 GLOG_vmodule=transaction=1,engine_shard_set=1
GLOG_logtostderr=1 GLOG_vmodule=transaction=1,engine_shard_set=1 ./tiered_storage_test
GLOG_logtostderr=1 GLOG_vmodule=rdb_load=1,rdb_save=1,snapshot=1 ctest -V -L DFLY
./dragonfly_test --gtest_repeat=10
./multi_test --multi_exec_mode=2 --gtest_repeat=10
Expand Down
4 changes: 2 additions & 2 deletions src/server/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class Transaction;
class EngineShard;

struct KeyLockArgs {
DbIndex db_index;
DbIndex db_index = 0;
ArgSlice args;
unsigned key_step;
unsigned key_step = 1;
};

// Describes key indices.
Expand Down
3 changes: 3 additions & 0 deletions src/server/debugcmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ void DebugCmd::PopulateRangeFiber(uint64_t from, uint64_t len, std::string_view
void DebugCmd::Inspect(string_view key) {
EngineShardSet& ess = *shard_set;
ShardId sid = Shard(key, ess.size());
VLOG(1) << "DebugCmd::Inspect " << key;

auto cb = [&]() -> ObjInfo {
auto& db_slice = EngineShard::tlocal()->db_slice();
Expand Down Expand Up @@ -383,7 +384,9 @@ void DebugCmd::Inspect(string_view key) {

KeyLockArgs lock_args;
lock_args.args = ArgSlice{&key, 1};
lock_args.key_step = 1;
lock_args.db_index = cntx_->db_index();

if (!db_slice.CheckLock(IntentLock::EXCLUSIVE, lock_args)) {
oinfo.lock_status =
db_slice.CheckLock(IntentLock::SHARED, lock_args) ? ObjInfo::S : ObjInfo::X;
Expand Down
2 changes: 1 addition & 1 deletion src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ fibers::future<std::error_code> ServerFamily::Load(const std::string& load_path)
// Check all paths are valid.
for (const auto& path : paths) {
error_code ec;
fs::canonical(path, ec);
auto canonical_path = fs::canonical(path, ec);
if (ec) {
LOG(ERROR) << "Error loading " << load_path << " " << ec.message();
fibers::promise<std::error_code> ec_promise;
Expand Down
7 changes: 6 additions & 1 deletion src/server/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,12 @@ OpStatus Transaction::ScheduleSingleHop(RunnableType cb) {
CHECK_GE(DecreaseRunCnt(), 1u);
}
};
shard_set->Add(unique_shard_id_, std::move(schedule_cb)); // serves as a barrier.

if (coordinator_index_ == unique_shard_id_) {
schedule_cb();
} else {
shard_set->Add(unique_shard_id_, std::move(schedule_cb)); // serves as a barrier.
}
} else {
// This transaction either spans multiple shards and/or is multi.

Expand Down

0 comments on commit 5f92f84

Please sign in to comment.