From b629dc1cd1b2ebe4c60f0b64c4589c174e9a2343 Mon Sep 17 00:00:00 2001 From: thawk105 Date: Wed, 26 Aug 2026 17:10:41 +0900 Subject: [PATCH] Add the missing YCSB entrypoint for SS2PL `cc/ss2pl/CMakeLists.txt` registered only `bomb` and `tpcc`, so no `ycsb_ss2pl.exe` was ever built and SS2PL could not be measured on YCSB at all. `cmake --build --target ycsb_ss2pl.exe` fails with "No rule to make target". The pre-cmake YCSB main survived as `cc/ss2pl/ss2pl.cc`, but it is dead code: it is outside the build graph (the `ccbench_add_protocol` convention picks up `_.cc`, which it does not match) and it calls the two-argument `TxExecutor` constructor that no longer exists. Nothing references it, so remove it rather than leave a file that cannot compile. - add `cc/ss2pl/ycsb_ss2pl.cc`, modelled on `cc/silo/ycsb_silo.cc` and `cc/ss2pl/bomb_ss2pl.cc`: the shared `ccbench::run` runner with the current three-argument factory - add `ycsb` to the protocol's `WORKLOADS` - delete the dead `cc/ss2pl/ss2pl.cc` - mark SS2PL's YCSB column as supported in `README.md` and in both `docs/protocols_ja.md` and `docs/protocols_en.md` (each has a protocol table and a matrix snapshot; the snapshots were checked against a regenerated `build/PROTOCOL_MATRIX.md`, which is not committed) Not changed on purpose: - `cc/ss2pl/util.cc` is untouched. `chkArg()` validates the protocol-local legacy `FLAGS_rratio` rather than the `FLAGS_ycsb_rratio` the YCSB workload actually reads, but that mismatch is repo-wide (`cc/silo` disabled the same check) and fixing it only for this binary would make SS2PL's YCSB entrypoint behave differently from every other one. - With `ycsb_ss2pl.exe` in place, YCSB aborts are counted twice: once in `TxExecutor::abort()` and once in the workload loop in `include/ycsb.hh`. That is a pre-existing issue in the shared workload header, not specific to SS2PL, and is left for a separate change. - The per-protocol `README.md` and `script/*.sh` still refer to the old `ss2pl.exe` name and positional CLI. The same staleness exists under `cc/silo/`, so it is out of scope here. Verified on an Intel Xeon Platinum 8468 (48 physical cores): - `cmake --build` of every protocol with `-DCMAKE_BUILD_TYPE=Release`, `-Wall -Wextra -Werror`, under g++ 11.4 and g++ 12 - `ycsb_ss2pl.exe -ycsb_tuple_num=1000000 -ycsb_max_ope=10 -ycsb_rratio=50 -ycsb_zipf_skew=0 -thread_num=48 -extime=5` exits 0 at 7,800,905 tps (abort rate 0.0031) - `tpcc_ss2pl.exe` and `bomb_ss2pl.exe` are unaffected: their `.text` sections are byte-identical to a build of the parent commit - the `clang-format --dry-run --Werror` check from `.github/workflows/format.yml` passes with clang-format 14 GCC 13, which CI uses, was not available on the test machine, so the `-Werror` result there is unverified. This change was written with AI assistance. --- README.md | 3 +- cc/ss2pl/CMakeLists.txt | 2 +- cc/ss2pl/ss2pl.cc | 122 ---------------------------------------- cc/ss2pl/ycsb_ss2pl.cc | 42 ++++++++++++++ docs/protocols_en.md | 4 +- docs/protocols_ja.md | 4 +- 6 files changed, 49 insertions(+), 128 deletions(-) delete mode 100644 cc/ss2pl/ss2pl.cc create mode 100644 cc/ss2pl/ycsb_ss2pl.cc 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/` | — | — | ✓ | ✓ | ✓ |