diff --git a/README.md b/README.md index cff93802..a5e0c2ec 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ The repository now also bundles the **TPC-C** and **BoMB** workloads, and severa | Protocol | YCSB | TPC-C | BoMB | |---|:-:|:-:|:-:| | Silo, MOCC, Cicada, ERMIA, TicToc, Oze, SI | ✓ | ✓ | ✓ | -| SS2PL, MVTO | — | ✓ | ✓ | +| SS2PL | ✓ | ✓ | ✓ | +| MVTO | — | ✓ | ✓ | | D2PL | — | — | ✓ | See [docs/workloads_en.md](docs/workloads_en.md) for the workload specs (tables, transactions, parameters) and [docs/protocols_en.md](docs/protocols_en.md) for the full protocol matrix. diff --git a/cc/ss2pl/CMakeLists.txt b/cc/ss2pl/CMakeLists.txt index 7cc2f407..4906a488 100644 --- a/cc/ss2pl/CMakeLists.txt +++ b/cc/ss2pl/CMakeLists.txt @@ -1,6 +1,6 @@ ccbench_add_protocol(ss2pl SOURCES transaction.cc util.cc - WORKLOADS bomb tpcc + WORKLOADS ycsb bomb tpcc OPTIONS DLR1 KEY_SORT=${CCBENCH_KEY_SORT} diff --git a/cc/ss2pl/ss2pl.cc b/cc/ss2pl/ss2pl.cc deleted file mode 100644 index 2628f4e2..00000000 --- a/cc/ss2pl/ss2pl.cc +++ /dev/null @@ -1,122 +0,0 @@ - -#include //isdigit, -#include -#include //strlen, -#include //syscall(SYS_gettid), -#include //syscall(SYS_gettid), -#include //syscall(SYS_gettid), -#include - -#include -#include //string -#include - -#define GLOBAL_VALUE_DEFINE - -#include "../../include/atomic_wrapper.hh" -#include "../../include/backoff.hh" -#include "../../include/cpu.hh" -#include "../../include/debug.hh" -#include "../../include/fence.hh" -#include "../../include/int64byte.hh" -#include "../../include/masstree_wrapper.hh" -#include "../../include/procedure.hh" -#include "../../include/random.hh" -#include "../../include/result.hh" -#include "../../include/tsc.hh" -#include "../../include/util.hh" -#include "../../include/zipf.hh" -#include "include/common.hh" -#include "include/result.hh" -#include "include/transaction.hh" -#include "include/util.hh" - -void worker(size_t thid, char& ready, const bool& start, const bool& quit) { - Result& myres = std::ref(CCBenchResults[thid]); - Xoroshiro128Plus rnd; - rnd.init(); - TxExecutor trans(thid, (Result*) &myres); - FastZipf zipf(&rnd, FLAGS_zipf_skew, FLAGS_tuple_num); - Backoff backoff(FLAGS_clocks_per_us); - -#if MASSTREE_USE - MasstreeWrapper::thread_init(int(thid)); -#endif - -#ifdef Linux - setThreadAffinity(thid); - // printf("Thread #%d: on CPU %d\n", *myid, sched_getcpu()); - // printf("sysconf(_SC_NPROCESSORS_CONF) %ld\n", - // sysconf(_SC_NPROCESSORS_CONF)); -#endif // Linux - - storeRelease(ready, 1); - while (!loadAcquire(start)) _mm_pause(); - while (!loadAcquire(quit)) { - makeProcedure(trans.pro_set_, rnd, zipf, FLAGS_tuple_num, FLAGS_max_ope, - FLAGS_thread_num, FLAGS_rratio, FLAGS_rmw, FLAGS_ycsb, false, - thid, myres); - RETRY: - if (loadAcquire(quit)) break; - if (thid == 0) leaderBackoffWork(backoff, CCBenchResults); - - trans.begin(); - for (auto itr = trans.pro_set_.begin(); itr != trans.pro_set_.end(); - ++itr) { - if ((*itr).ope_ == Ope::READ) { - trans.read((*itr).key_); - } else if ((*itr).ope_ == Ope::WRITE) { - trans.update((*itr).key_); - } else if ((*itr).ope_ == Ope::READ_MODIFY_WRITE) { - trans.readWrite((*itr).key_); - } else { - ERR; - } - - if (trans.status_ == TransactionStatus::aborted) { - trans.abort(); - goto RETRY; - } - } - - trans.commit(); - /** - * local_commit_counts is used at ../include/backoff.hh to calcurate about - * backoff. - */ - storeRelease(myres.local_commit_counts_, - loadAcquire(myres.local_commit_counts_) + 1); - } - - return; -} - -int main(int argc, char* argv[]) try { - gflags::SetUsageMessage("2PL benchmark."); - gflags::ParseCommandLineFlags(&argc, &argv, true); - chkArg(); - makeDB(); - - alignas(CACHE_LINE_SIZE) bool start = false; - alignas(CACHE_LINE_SIZE) bool quit = false; - initResult(TotalThreadNum); - std::vector readys(FLAGS_thread_num); - std::vector thv; - for (size_t i = 0; i < FLAGS_thread_num; ++i) - thv.emplace_back(worker, i, std::ref(readys[i]), std::ref(start), - std::ref(quit)); - waitForReady(readys); - storeRelease(start, true); - for (size_t i = 0; i < FLAGS_extime; ++i) { sleepMs(1000); } - storeRelease(quit, true); - for (auto& th : thv) th.join(); - - for (unsigned int i = 0; i < FLAGS_thread_num; ++i) { - CCBenchResults[0].addLocalAllResult(CCBenchResults[i]); - } - ShowOptParameters(); - CCBenchResults[0].displayAllResult(FLAGS_clocks_per_us, FLAGS_extime, - FLAGS_thread_num); - - return 0; -} catch (bad_alloc) { ERR; } diff --git a/cc/ss2pl/ycsb_ss2pl.cc b/cc/ss2pl/ycsb_ss2pl.cc new file mode 100644 index 00000000..52bb012e --- /dev/null +++ b/cc/ss2pl/ycsb_ss2pl.cc @@ -0,0 +1,42 @@ +#define GLOBAL_VALUE_DEFINE + +#include "include/common.hh" +#include "include/result.hh" +#include "include/transaction.hh" +#include "include/util.hh" + +#include "../../include/cpu.hh" +#include "../../include/debug.hh" +#include "../../include/masstree_wrapper.hh" +#include "../../include/result.hh" +#include "../../include/tsc.hh" +#include "../../include/util.hh" +#include "../../include/ycsb.hh" + +#include "../../common/runner.hh" + +int main(int argc, char* argv[]) try { + gflags::SetUsageMessage("YCSB SS2PL benchmark."); + gflags::ParseCommandLineFlags(&argc, &argv, true); + chkArg(); + YcsbWorkload::displayWorkloadParameter(); + YcsbWorkload::makeDB(nullptr); + + initResult(TotalThreadNum); + + ccbench::run( + TotalThreadNum, ccbench::RunnerOptions{}, + [](std::size_t thid, const bool& quit, Backoff& /*unused*/) { + return TxExecutor(thid, &CCBenchResults[thid], quit); + }, + [](TxExecutor& /*trans*/, std::size_t thid) { +#ifdef Linux + setThreadAffinity(thid); +#endif +#if MASSTREE_USE + MasstreeWrapper::thread_init(static_cast(thid)); +#endif + }); + + return 0; +} catch (const std::bad_alloc&) { ERR; } diff --git a/docs/protocols_en.md b/docs/protocols_en.md index 132c61cb..2f22d274 100644 --- a/docs/protocols_en.md +++ b/docs/protocols_en.md @@ -15,7 +15,7 @@ for the declarative helper). All are driven from the top-level | [cc/ermia](../cc/ermia/) | ERMIA (with SSN / latch-free SSN) | ✓ | ✓ | ✓ | Kim et al., SIGMOD 2016; Wang et al., VLDB 2017 | | [cc/oze](../cc/oze/) | Oze | ✓ | ✓ | ✓ | Multi-version OCC variant | | [cc/si](../cc/si/) | Snapshot Isolation | ✓ | ✓ | ✓ | ERMIA without the SSN layer (no anti-dependency check) | -| [cc/ss2pl](../cc/ss2pl/) | Strong Strict 2-Phase Locking | — | ✓ | ✓ | Baseline locking | +| [cc/ss2pl](../cc/ss2pl/) | Strong Strict 2-Phase Locking | ✓ | ✓ | ✓ | Baseline locking | | [cc/d2pl](../cc/d2pl/) | Deterministic 2PL | — | — | ✓ | sBoMB and dBoMB only; pre-declared lock entries make TPC-C templates inapplicable | | [cc/mvto](../cc/mvto/) | Multi-Version Timestamp Ordering | — | ✓ | ✓ | Reed, 1978 | @@ -41,7 +41,7 @@ argument of every `ccbench_add_protocol(...)` call. The current snapshot: | `cc/tictoc/` | ✓ | ✓ | ✓ | ✓ | — | | `cc/oze/` | ✓ | ✓ | ✓ | — | — | | `cc/si/` | ✓ | ✓ | ✓ | ✓ | — | -| `cc/ss2pl/` | — | ✓ | ✓ | — | — | +| `cc/ss2pl/` | ✓ | ✓ | ✓ | — | — | | `cc/mvto/` | — | ✓ | ✓ | — | — | | `cc/d2pl/` | — | — | ✓ | ✓ | ✓ | diff --git a/docs/protocols_ja.md b/docs/protocols_ja.md index 94370618..cf3e62c3 100644 --- a/docs/protocols_ja.md +++ b/docs/protocols_ja.md @@ -11,7 +11,7 @@ | [cc/ermia](../cc/ermia/) | ERMIA (with SSN / latch-free SSN) | ✓ | ✓ | ✓ | Kim et al., SIGMOD 2016; Wang et al., VLDB 2017 | | [cc/oze](../cc/oze/) | Oze | ✓ | ✓ | ✓ | Multi-version OCC の派生 | | [cc/si](../cc/si/) | Snapshot Isolation | ✓ | ✓ | ✓ | ERMIA から SSN レイヤを剥がしたもの (anti-dependency チェック無し) | -| [cc/ss2pl](../cc/ss2pl/) | Strong Strict 2-Phase Locking | — | ✓ | ✓ | ベースラインのロック方式 | +| [cc/ss2pl](../cc/ss2pl/) | Strong Strict 2-Phase Locking | ✓ | ✓ | ✓ | ベースラインのロック方式 | | [cc/d2pl](../cc/d2pl/) | Deterministic 2PL | — | — | ✓ | sBoMB と dBoMB のみサポート。pre-declared lock entries が必要なため TPC-C テンプレートには適用不能 | | [cc/mvto](../cc/mvto/) | Multi-Version Timestamp Ordering | — | ✓ | ✓ | Reed, 1978 | @@ -30,7 +30,7 @@ | `cc/tictoc/` | ✓ | ✓ | ✓ | ✓ | — | | `cc/oze/` | ✓ | ✓ | ✓ | — | — | | `cc/si/` | ✓ | ✓ | ✓ | ✓ | — | -| `cc/ss2pl/` | — | ✓ | ✓ | — | — | +| `cc/ss2pl/` | ✓ | ✓ | ✓ | — | — | | `cc/mvto/` | — | ✓ | ✓ | — | — | | `cc/d2pl/` | — | — | ✓ | ✓ | ✓ |