Skip to content

[P0] common/ を静的ライブラリ化する - #39

Merged
thawk105 merged 1 commit into
masterfrom
p0-common-library
May 12, 2026
Merged

[P0] common/ を静的ライブラリ化する#39
thawk105 merged 1 commit into
masterfrom
p0-common-library

Conversation

@thawk105

Copy link
Copy Markdown
Owner

Closes #30.

What

Top-level CMakeLists.txt:

  • add_library(ccbench_common STATIC common/result.cc common/util.cc).
    PUBLIC link: Threads / Boost::filesystem / gflags / glog.
    PUBLIC include: source root (so ../include/foo.hh resolves transitively).
  • Imported targets ccbench::masstree and ccbench::mimalloc for the
    bootstrap-built static archives — replaces the raw
    \${THIRD_PARTY_DIR}/.../*.a paths.

Each protocol's CMakeLists.txt:

  • Drop "../common/result.cc" and "../common/util.cc" from file(GLOB).
  • Replace the per-binary target_link_libraries(<bin> ... ) blocks with a
    single foreach(t <bins...>) target_link_libraries(\${t} PRIVATE ccbench_common ccbench::masstree ccbench::mimalloc) endforeach().

CRLF -> LF on silo/ss2pl/cicada/mocc/ermia/CMakeLists.txt.

Why

`common/result.cc` and `common/util.cc` were being recompiled separately for every one of the 28 binaries. ccache was masking the duplication; the CI workflow's own comment was candid about it.

Verified

  • All 34 binaries build (Release, Debug+ASan).
  • `common/{result,util}.cc.o` now produced exactly once per build directory (was 28 times).
  • Smoke runs of `tpcc_.exe` across silo/mocc/cicada/ermia/tictoc/oze/ss2pl/mvto/si all return non-zero throughput.
  • Debug+ASan smoke of tpcc_silo (4t/4wh) and tpcc_si (4t/4wh) clean apart from the pre-existing MVCC version leak (unrelated to this change).

Out of scope (tracked separately)

Diff highlights

```
CMakeLists.txt | +33
silo/CMakeLists.txt | -286 -> -100ish (similar pattern across 9 protocols)
11 files changed, +1027 -1247
```

…#30)

Closes #30.

Before this change, every protocol's CMakeLists.txt added common/result.cc
and common/util.cc into each binary's source list via file(GLOB), causing
those two files to be compiled separately for every one of the 28 binaries.
ccache was masking the duplication. The CI workflow's own comment was
candid about it ("ccache deduplicates compilations across the 28
binaries... each protocol's CMakeLists.txt currently compiles common/*.cc
and its own .cc files separately for every target").

Top-level CMakeLists.txt now:
  - Defines `ccbench_common` (STATIC) compiling common/{result,util}.cc once.
    PUBLIC link inheritance: Threads / Boost::filesystem / gflags / glog.
    PUBLIC include of the source root so ../include/foo.hh paths from the
    protocol dirs resolve through the library.
  - Defines imported targets `ccbench::masstree` and `ccbench::mimalloc`
    pointing at the bootstrap-built static archives in third_party/, so
    the raw paths stop being copy-pasted into every protocol.

Each protocol's CMakeLists.txt now:
  - Drops `../common/result.cc` and `../common/util.cc` from its file(GLOB)
    blocks.
  - Replaces the per-binary `target_link_libraries(<bin> Boost::filesystem
    gflags::gflags <THIRD_PARTY_DIR>/mimalloc/...a <THIRD_PARTY_DIR>/
    masstree/...a Threads::Threads)` block with a single foreach() that
    links each binary against ccbench_common + ccbench::masstree +
    ccbench::mimalloc PRIVATE.

CRLF -> LF on the five CMakeLists.txt that had CRLF: silo/, ss2pl/,
cicada/, mocc/, ermia/.

Verified:
  - Build succeeds for all 34 binaries (Release, Debug+ASan).
  - common/result.cc.o and common/util.cc.o are now produced exactly
    once each per build directory (was 28 times).
  - Smoke runs of tpcc_<protocol>.exe across silo/mocc/cicada/ermia/
    tictoc/oze/ss2pl/mvto/si all return non-zero throughput in Release.
  - Debug+ASan smoke of tpcc_silo (4t/4wh) and tpcc_si (4t/4wh) clean
    apart from the pre-existing MVCC version-leak in si/ermia (unrelated
    to this change).

Out of scope (other Pn issues):
  - Per-protocol result.cc/util.cc still exist (P2 / #33).
  - add_definitions(...) blocks unchanged (P4 / #37).
  - cc_format/ untouched (P5 / #34).
  - oze/ still references THIRD_PARTY_DIR for googletest include
    (P8 / FetchContent territory in #37).
@thawk105
thawk105 merged commit dbbe98f into master May 12, 2026
2 checks passed
@thawk105
thawk105 deleted the p0-common-library branch May 12, 2026 20:56
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.

[P0] common/ を静的ライブラリ化する

1 participant