Skip to content

Commit

Permalink
WIP: waiting bypass on/off (compile-time)
Browse files Browse the repository at this point in the history
  • Loading branch information
ban-nobuhiro committed Jan 1, 2024
1 parent 55c693f commit 3b0436d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ option(BUILD_SHARED_LIBS "build shared libraries instead of static" ON)
option(BUILD_PWAL "Build parallel write ahead logging as logging." ON)
option(PWAL_ENABLE_READ_LOG "PWAL log read (/ write) informations to verify whether committed schedule is valid." OFF)

# features
option(ENABLE_WAITING_BYPASS "enable waiting bypass" ON)
option(WAITING_BYPASS_TO_ROOT "waiting bypass to root" OFF)

# shutdown shortcut
option(TSURUGI_FAST_SHUTDOWN "enable shortcuts during shutdown process by default" OFF)

Expand Down
8 changes: 8 additions & 0 deletions cmake/CompileOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ elseif (BUILD_CPR)
else ()
message("It uses no logging method.")
endif ()
if (ENABLE_WAITING_BYPASS)
add_definitions(-DWAITING_BYPASS=1)
if (WAITING_BYPASS_TO_ROOT)
add_definitions(-DWAITING_BYPASS_ROOT=1)
endif ()
else()
add_definitions(-DWAITING_BYPASS=0)
endif ()

if (TSURUGI_FAST_SHUTDOWN)
add_definitions(-DTSURUGI_FAST_SHUTDOWN_ON)
Expand Down
20 changes: 19 additions & 1 deletion src/concurrency_control/ongoing_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

namespace shirakami {

#ifndef WAITING_BYPASS
#define WAITING_BYPASS 1
#endif

bool ongoing_tx::exist_id(std::size_t id) {
std::shared_lock<std::shared_mutex> lk{mtx_};
for (auto&& elem : tx_info_) {
Expand Down Expand Up @@ -39,11 +43,13 @@ Status ongoing_tx::waiting_bypass(session* ti) {
// found
auto* token = std::get<ongoing_tx::index_session>(elem);

#ifndef WAITING_BYPASS_TO_ROOT
// check exist living wait for, for not to remove path to root.
if (!exist_living_wait_for(token)) {
// not bypass for tree root
continue;
}
#endif

bypass_target.insert(std::make_tuple(the_tx_id, token));
// set valid epoch if need
Expand Down Expand Up @@ -193,10 +199,22 @@ bool ongoing_tx::exist_wait_for(session* ti, Status& out_status) {
* に対する前置を確定するとともに、x1 が前置する相手に前置する。
* これは待ち確認のたびにパスを一つ短絡化するため、
* get_requested_commit() の確認を噛ませていない。
*/
bool do_waiting_bypass; // NOLINT
#if WAITING_BYPASS
# ifdef WAITING_BYPASS_TO_ROOT
do_waiting_bypass = true;
# else
/**
* https://github.com/project-tsurugi/tsurugi-issues/issues/438#issuecomment-1839876140
* ルートになるまでパスを縮めてはいけない。
*/
if (wait_for.size() > 2) {
do_waiting_bypass = (wait_for.size() > 2);
# endif
#else
do_waiting_bypass = false;
#endif
if (do_waiting_bypass) {
out_status = waiting_bypass(ti);
}
return true;
Expand Down

0 comments on commit 3b0436d

Please sign in to comment.