chore: change thread_local to __thread when possible.

This should reduce the access cost to thread_local objects.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2023-03-12 20:05:33 +02:00 committed by Roman Gershman
parent 149b1fa913
commit bac9180602
7 changed files with 26 additions and 17 deletions

View file

@ -18,7 +18,7 @@ ABSL_FLAG(uint32_t, interpreter_per_thread, 10, "Lua interpreters per thread");
namespace dfly {
thread_local ServerState ServerState::state_;
__thread ServerState* ServerState::state_ = nullptr;
void MonitorsRepo::Add(facade::Connection* connection) {
VLOG(1) << "register connection "
@ -60,12 +60,14 @@ ServerState::~ServerState() {
}
void ServerState::Init(uint32_t thread_index) {
gstate_ = GlobalState::ACTIVE;
thread_index_ = thread_index;
state_ = new ServerState();
state_->gstate_ = GlobalState::ACTIVE;
state_->thread_index_ = thread_index;
}
void ServerState::Shutdown() {
gstate_ = GlobalState::SHUTTING_DOWN;
void ServerState::Destroy() {
delete state_;
state_ = nullptr;
}
Interpreter* ServerState::BorrowInterpreter() {