[P1] TxExecutor契約をコンパイル時に強制する + tx.write→tx.update rename - #40
Merged
Conversation
…tx.update (#31) Closes #31. ## Contract enforcement Add include/tx_executor_concept.hh defining `TxExecutorLike<T>`. Each protocol's `transaction.hh` ends with `static_assert(TxExecutorLike<TxExecutor>);` so a missing or wrong-signature method fails the protocol's own build with a named diagnostic instead of crashing at runtime in some workload. Caught d2pl missing the `scan(..., int64_t limit)` overload — added the overload (forwarding to the unlimited form with -1) so d2pl now satisfies the contract uniformly with the other 9 protocols. The check uses an `is_detected`-style SFINAE helper instead of a C++20 `concept` because the bundled `masstree-beta` upstream still calls `std::allocator::construct/destroy`, which were removed in C++20. Bumping the tree to C++20 broke masstree's `small_vector::rep`. Filing this as a separate concern; for now the SFINAE path gives the same compile-time guarantee in C++17. ## tx.write -> tx.update rename `tx.write` was misnamed: it operates only on existing rows (returns `WARN_NOT_FOUND` otherwise) and internally tags the write set with `OpType::UPDATE`. Renaming aligns the API with SQL CRUD: read / update / insert / delete_record / scan `write_set_`, `write_phase`, etc. keep the "write" terminology — the set holds insert + update + delete ops collectively, and matches Silo / Cicada / ERMIA paper terminology. Touched 32 files, mechanical replace of `tx.write(` -> `tx.update(` and the matching method definitions/declarations. `tx.write_lock(...)` (a separate ss2pl/d2pl-only API) is intentionally untouched. ## Verified - All 34 binaries build (Release + Debug+ASan). - 9 TPC-C smoke runs all return non-zero throughput. - Negative test: deliberately removing `update` from silo's TxExecutor triggers the static_assert with a clear diagnostic. ## Out of scope - masstree C++20 incompatibility (separate; would unlock real C++20 `concept` syntax in this repo). - legacy `void write(uint64_t key)` decls in ss2pl/d2pl (no impl, no callers; defer to P7 dead-code sweep #36). - workload-template-side `<TxExecutorLike Tx, ...>` constraint not added — per-protocol static_assert already catches violations earlier and locally.
Now that thawk105/masstree-beta#1 is in (refcount as std::atomic, rep construct/destroy via std::allocator_traits), the bundled masstree header compiles cleanly under -std=c++20, so the rest of the tree can use C++20 too: - cmake/CompileOptions.cmake: CMAKE_CXX_STANDARD 17 -> 20. - top-level CMakeLists.txt: ccbench_common now requires cxx_std_20 PUBLICly, so consumers inherit the standard. - third_party/masstree submodule: bump to b3c5d05 (the merged PR). - include/tx_executor_concept.hh: replace the is_detected-style SFINAE scaffolding with a real `requires`-clause C++20 concept. The per-protocol `static_assert(TxExecutorLike<TxExecutor>)` checks now fail with much sharper diagnostics — constraints not satisfied the required expression 't.update(s, k, declval<TupleBody&&>())' is invalid (verified by removing `update` from silo's TxExecutor and rebuilding.)
Owner
Author
|
追加コミット
これで (silo から 全 34 バイナリ Release ビルド clean、warning ゼロ。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31.
What
include/tx_executor_concept.hhにTxExecutorLike<T>を新設。各プロトコルのtransaction.hh末尾にstatic_assert(TxExecutorLike<TxExecutor>);を追加 → 契約違反がプロトコル自身のビルド時に named diagnostic で落ちる。tx.write→tx.updaterename を repo 全体に。理由: 既存行への書き込み専用(行が無いとWARN_NOT_FOUND、内部OpType::UPDATE)で、writeという名前が誤解を招くため。SQL CRUD と揃えた:read / update / insert / delete_record / scand2pl が
scan(..., int64_t limit)overload 不足 を契約検査が捕捉 → overload 追加(-1で無制限版に forward)。SFINAE である理由
issue spec は C++20
conceptを要求してるが、bundledmasstree-betaがstd::allocator::construct/destroy(C++20で削除)を呼んでてビルド不可。C++17 に留まったままis_detected風 SFINAE で同等の検査を実装。masstree 側の C++20 対応は別 issue 案件。動作確認
silo/include/transaction.hhのupdateをupdate_DISABLEDに rename したら:Out of scope
concept構文を解禁したいなら別 issue 必要。void write(uint64_t key)宣言: 実装/呼び出し共に無し。P7 dead-code sweep ([P7] デッドコード・残骸ファイルを一掃する #36) で。<TxExecutorLike Tx, ...>制約: per-protocol static_assert で先に / 局所的に検出されるので redundant、省略。統計