mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
opt(server): Migrate connections which invoke Lua scripts to their target thread. (#2037)
This is enabled by default, but can be disabled via `--migrate_connections=false`. Measuring with BullMQ benchmark I see a gain of almost 10% in throughput. I haven't measured, but it's supposed to also reduce latency.
This commit is contained in:
parent
395f65ddd2
commit
bc0064e94d
3 changed files with 120 additions and 12 deletions
|
@ -1606,6 +1606,7 @@ void Service::EvalInternal(CmdArgList args, const EvalArgs& eval_args, Interpret
|
|||
// we can do it once during script insertion into script mgr.
|
||||
auto& sinfo = cntx->conn_state.script_info;
|
||||
sinfo = make_unique<ConnectionState::ScriptInfo>();
|
||||
sinfo->keys.reserve(eval_args.keys.size());
|
||||
|
||||
optional<ShardId> sid;
|
||||
for (size_t i = 0; i < eval_args.keys.size(); ++i) {
|
||||
|
@ -1654,6 +1655,11 @@ void Service::EvalInternal(CmdArgList args, const EvalArgs& eval_args, Interpret
|
|||
});
|
||||
|
||||
cntx->transaction = tx;
|
||||
if (*sid != ServerState::tlocal()->thread_index()) {
|
||||
VLOG(1) << "Migrating connection " << cntx->conn() << " from " << ProactorBase::GetIndex()
|
||||
<< " to " << *sid;
|
||||
cntx->conn()->RequestAsyncMigration(shard_set->pool()->at(*sid));
|
||||
}
|
||||
} else {
|
||||
optional<bool> scheduled = StartMultiEval(cntx->db_index(), eval_args.keys, *params, cntx);
|
||||
if (!scheduled) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue