Skip to content

P3: declarative ccbench_add_protocol() + move protocols under cc/ (closes #32) - #41

Merged
thawk105 merged 1 commit into
masterfrom
p3-declarative-cmake
May 12, 2026
Merged

P3: declarative ccbench_add_protocol() + move protocols under cc/ (closes #32)#41
thawk105 merged 1 commit into
masterfrom
p3-declarative-cmake

Conversation

@thawk105

Copy link
Copy Markdown
Owner

Summary

Closes #32.

  • New cmake/ProtocolHelpers.cmake exposes ccbench_add_protocol(<name> SOURCES ... WORKLOADS ... OPTIONS ...). Each protocol's CMakeLists.txt collapses from ~70-130 lines of file(GLOB) + add_executable + add_definitions boilerplate into a single declarative call (6-19 lines).
  • New cmake/Options.cmake centralises the universal -D flags as CCBENCH_* cache entries (KEY_SIZE, BACK_OFF, VAL_SIZE, etc.), replacing the ~180 directory-scoped add_definitions(...) calls duplicated across protocols. Override on the cmake command line: cmake -S . -B build -DCCBENCH_KEY_SIZE=16 -DCCBENCH_BACK_OFF=0.
  • All flags are now target_compile_definitions(... PRIVATE ...) — no more directory-scope leak.
  • ccbench_write_protocol_matrix() dumps build/PROTOCOL_MATRIX.md from the WORKLOADS arg of every call, so the support table in CLAUDE.md / docs/protocols.md can be refreshed mechanically.
  • Bonus reorg: all 10 protocols moved from <name>/ to cc/<name>/. Binaries now land in build/cc/<protocol>/<workload>_<protocol>.exe; docs updated to match.

Completion criteria (from #32)

  • Each protocol's CMakeLists.txt is ~10-20 lines
  • Zero add_definitions(...) calls remain
  • All protocols build (Debug+ASan and Release verified locally — 34/34 binaries)
  • CI green (this PR will exercise it)

Notes / follow-ups

  • The helper deliberately does not call set_compile_options() (-Wall -Wextra -Werror). The old per-protocol CMakeLists never enabled -Werror, the source tree has accumulated warnings under those flags (ermia/scan_callback, masstree_wrapper, ...), and turning it on here would mix in a separate cleanup. Left as a follow-up.
  • Some <protocol>.cc files (e.g. cc/cicada/cicada.cc) are legacy standalone YCSB mains that the old CMake silently excluded — kept in tree but not in SOURCES. Could be removed in a separate cleanup.
  • occ/ is still not wired into CMake; not moved under cc/ this PR.

Test plan

  • cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug && cmake --build build -j succeeds locally (34 binaries)
  • cmake -S . -B build-release -DCMAKE_BUILD_TYPE=Release -DENABLE_SANITIZER=OFF && cmake --build build-release -j succeeds locally (34 binaries)
  • Smoke-run: ./build/cc/silo/ycsb_silo.exe -thread_num=2 -extime=1 -clocks_per_us=2100 shows both universal and silo-specific -D flags applied
  • CI passes

)

Each protocol's CMakeLists.txt collapses from ~70-130 lines of file(GLOB)
+ add_executable + add_definitions boilerplate into a single declarative
call:

    ccbench_add_protocol(<name>
      SOURCES   <shared .cc files>
      WORKLOADS ycsb tpcc bomb sbomb
      OPTIONS   FOO=${CCBENCH_FOO} ...)

- New cmake/ProtocolHelpers.cmake exposes ccbench_add_protocol() and a
  ccbench_write_protocol_matrix() that writes build/PROTOCOL_MATRIX.md
  from the WORKLOADS arg of every call — no more manual sync between
  CLAUDE.md / docs/protocols.md and the build system.
- New cmake/Options.cmake centralises the universal -D flags as CACHE
  entries (CCBENCH_KEY_SIZE, CCBENCH_BACK_OFF, CCBENCH_VAL_SIZE, ...),
  replacing the ~180 directory-scoped add_definitions(...) calls
  duplicated across protocols. Override on the cmake command line:
    cmake -S . -B build -DCCBENCH_KEY_SIZE=16 -DCCBENCH_BACK_OFF=0
- target_compile_definitions(... PRIVATE ...) is used throughout, so
  flags no longer leak via directory scope.

Protocol directories also move from <name>/ to cc/<name>/, grouping all
CC implementations under one parent. Binaries now land in
build/cc/<protocol>/<workload>_<protocol>.exe; docs and the runtime-args
examples are updated to match. Source-file relative includes were
shifted from ../include/... to ../../include/... to account for the
extra depth.

The helper deliberately does not call set_compile_options(): the old
per-protocol CMakeLists never enabled -Wall -Wextra -Werror, the source
tree has accumulated warnings under those flags, and turning -Werror on
here would mix in a separate cleanup. Left as a follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P3] 宣言的CMake関数 ccbench_add_protocol() を導入する

1 participant