Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 1 addition & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,11 @@ jobs:

steps:
- uses: actions/checkout@v6
with:
submodules: recursive

# actions/checkout writes its own safe.directory, but later steps
# invoke git from a fresh shell (`sh -e {0}`) where that scoped
# config is not always picked up. Set it once globally so every
# `git ...` call in this job — checkout's submodule walk, the
# bootstrap-key step, etc. — sees the workspace as safe.
# `git ...` call in this job sees the workspace as safe.
- name: Mark workspace as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

Expand All @@ -68,37 +65,6 @@ jobs:
ccache --max-size=400M
ccache --zero-stats

# Cache key invalidates when any submodule SHA or bootstrap script changes.
- name: Compute bootstrap cache key
id: bootstrap-key
run: |
git submodule status > .submodule-state
echo "hash=$(sha256sum .submodule-state build_tools/bootstrap*.sh | sha256sum | cut -c1-16)" >> "$GITHUB_OUTPUT"

- name: Restore third_party build cache
id: tp-cache
uses: actions/cache@v4
with:
path: |
third_party/masstree/lib*.a
third_party/masstree/config.h
third_party/masstree/config.status
third_party/mimalloc/out
third_party/googletest/build
key: tp-${{ runner.os }}-${{ steps.bootstrap-key.outputs.hash }}

- name: Build third-party (masstree)
if: steps.tp-cache.outputs.cache-hit != 'true'
run: ./build_tools/bootstrap.sh

- name: Build third-party (mimalloc)
if: steps.tp-cache.outputs.cache-hit != 'true'
run: ./build_tools/bootstrap_mimalloc.sh

- name: Build third-party (googletest)
if: steps.tp-cache.outputs.cache-hit != 'true'
run: ./build_tools/bootstrap_googletest.sh

- name: Configure (top-level cmake)
# Sanitizer adds significant link-time memory/cpu cost and CI does
# not run binaries, so it adds no value here. Use Release for the
Expand Down
9 changes: 0 additions & 9 deletions .gitmodules

This file was deleted.

17 changes: 5 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# protocol binary via ccbench_add_protocol() (see cmake/CompileOptions.cmake).
include(CompileOptions)

set(THIRD_PARTY_DIR "${PROJECT_SOURCE_DIR}/third_party/")

option(ENABLE_SANITIZER "enable sanitizer on debug build" ON)
option(ENABLE_UB_SANITIZER "enable undefined behavior sanitizer on debug build" OFF)
option(ENABLE_COVERAGE "enable coverage on debug build" OFF)
Expand All @@ -32,17 +30,12 @@ find_package(glog REQUIRED)
find_package(Boost COMPONENTS filesystem)

# ---------------------------------------------------------------------------
# Imported targets for the bootstrap-built third-party static libraries.
# Replaces the raw ${THIRD_PARTY_DIR}/.../*.a paths previously copy-pasted
# into every protocol's target_link_libraries(...).
# Third-party dependencies (masstree / mimalloc / googletest) are pulled in
# via FetchContent — see cmake/ThirdParty.cmake. Exposes ccbench::masstree
# / ccbench::mimalloc / GTest::gtest{,_main}, which replace the static
# IMPORTED targets and raw third_party/*.a paths used previously.
# ---------------------------------------------------------------------------
add_library(ccbench::masstree STATIC IMPORTED GLOBAL)
set_target_properties(ccbench::masstree PROPERTIES
IMPORTED_LOCATION "${THIRD_PARTY_DIR}/masstree/libkohler_masstree_json.a")

add_library(ccbench::mimalloc STATIC IMPORTED GLOBAL)
set_target_properties(ccbench::mimalloc PROPERTIES
IMPORTED_LOCATION "${THIRD_PARTY_DIR}/mimalloc/out/release/libmimalloc.a")
include(ThirdParty)

# ---------------------------------------------------------------------------
# common/ as a real shared static library — replaces the per-binary
Expand Down
9 changes: 0 additions & 9 deletions build_tools/bootstrap.sh

This file was deleted.

5 changes: 0 additions & 5 deletions build_tools/bootstrap_googletest.sh

This file was deleted.

24 changes: 0 additions & 24 deletions build_tools/bootstrap_mimalloc.sh

This file was deleted.

15 changes: 7 additions & 8 deletions cc/ss2pl/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,18 @@ foreach(src IN LISTS TEST_SOURCES)
KEY_SORT=${CCBENCH_KEY_SORT}
)

target_include_directories(${test_name}
PRIVATE ${PROJECT_SOURCE_DIR}/../third_party/googletest/googletest/include
)

# All three deps now come from FetchContent (cmake/ThirdParty.cmake) —
# GTest::gtest{,_main} carry their own INTERFACE_INCLUDE_DIRECTORIES so
# we no longer need the manual include path override.
target_link_libraries(${test_name}
Boost::filesystem
gflags::gflags
glog::glog
${PROJECT_SOURCE_DIR}/../third_party/mimalloc/out/release/libmimalloc.a
${PROJECT_SOURCE_DIR}/../third_party/masstree/libkohler_masstree_json.a
ccbench::mimalloc
ccbench::masstree
Threads::Threads
${PROJECT_SOURCE_DIR}/../third_party/googletest/build/lib/libgtest.a
${PROJECT_SOURCE_DIR}/../third_party/googletest/build/lib/libgtest_main.a
GTest::gtest
GTest::gtest_main
)
set_compile_options(${test_name})
add_test(
Expand Down
136 changes: 136 additions & 0 deletions cmake/ThirdParty.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# cmake/ThirdParty.cmake
#
# Centralised FetchContent declarations for ccbench's third-party
# dependencies. Replaces tracked submodules under third_party/ +
# the per-library build_tools/bootstrap_*.sh scripts.
#
# Targets exposed to the rest of the build:
# ccbench::masstree — static archive built from upstream sources
# (libkohler_masstree_json.a; same 11 objects the
# old build_tools/bootstrap.sh produced)
# ccbench::mimalloc — alias for the upstream mimalloc-static target
# GTest::gtest /
# GTest::gtest_main — provided directly by upstream googletest
#
# All revisions are pinned to commit SHAs / tags so the build is
# reproducible and FetchContent never silently follows a moving branch.

include(FetchContent)
include(ExternalProject)

# --- masstree --------------------------------------------------------------
#
# Upstream masstree-beta is not a CMake project (autotools + hand-rolled
# Makefile). We mirror the old build_tools/bootstrap.sh exactly:
# ./bootstrap.sh && ./configure --disable-assertions
# make CXXFLAGS='-g -W -Wall -O3 -fPIC'
# ar cr libkohler_masstree_json.a <11 objects> && ranlib …
# done at configure time via ExternalProject_Add, then exposed as a
# STATIC IMPORTED target so the rest of the CMake graph treats it the
# same way as before.
#
# The fork URL + commit SHA come from the previous .gitmodules /
# `git submodule status` (see issue #97).

set(CCBENCH_MASSTREE_REPO "https://github.com/thawk105/masstree-beta.git")
set(CCBENCH_MASSTREE_TAG "b3c5d054b66b08374d7a6ff5a0faeaf28b041a38")
set(CCBENCH_MIMALLOC_REPO "https://github.com/microsoft/mimalloc.git")
set(CCBENCH_MIMALLOC_TAG "v2.3.2") # commit 02a2f5d, matches old submodule
set(CCBENCH_GOOGLETEST_REPO "https://github.com/google/googletest.git")
set(CCBENCH_GOOGLETEST_TAG "f8d7d77c06936315286eb55f8de22cd23c188571")

FetchContent_Declare(
masstree
GIT_REPOSITORY "${CCBENCH_MASSTREE_REPO}"
GIT_TAG "${CCBENCH_MASSTREE_TAG}"
GIT_SHALLOW FALSE # SHA pin needs the full object, not a tag-only fetch
)

# Populate() leaves us with masstree_SOURCE_DIR / masstree_BINARY_DIR but
# does NOT add it to the build graph (the upstream tree has no
# CMakeLists.txt). We then drive its autotools build out-of-tree.
FetchContent_GetProperties(masstree)
if(NOT masstree_POPULATED)
FetchContent_Populate(masstree)
endif()

set(_masstree_archive "${masstree_SOURCE_DIR}/libkohler_masstree_json.a")
set(_masstree_config_h "${masstree_SOURCE_DIR}/config.h")

# Mirror the historical bootstrap.sh object set verbatim — these are the
# exact 11 translation units the old script packed into the archive.
set(_masstree_objs
json.o string.o straccum.o str.o msgpack.o clp.o
kvrandom.o compiler.o memdebug.o kvthread.o misc.o)

add_custom_command(
OUTPUT "${_masstree_archive}" "${_masstree_config_h}"
COMMAND ${CMAKE_COMMAND} -E echo "Building masstree (libkohler_masstree_json.a)"
COMMAND ./bootstrap.sh
COMMAND ./configure --disable-assertions
COMMAND make -j CXXFLAGS=-g\ -W\ -Wall\ -O3\ -fPIC
COMMAND ar cr libkohler_masstree_json.a ${_masstree_objs}
COMMAND ranlib libkohler_masstree_json.a
WORKING_DIRECTORY "${masstree_SOURCE_DIR}"
COMMENT "masstree: bootstrap + configure + make + ar"
VERBATIM
)
add_custom_target(masstree_build DEPENDS "${_masstree_archive}" "${_masstree_config_h}")

# Expose masstree as an INTERFACE library (rather than STATIC IMPORTED) so
# we can use add_dependencies() to wire the upstream-build custom target
# into every consumer — IMPORTED targets don't propagate build-order deps
# reliably across all CMake versions we care about.
add_library(ccbench_masstree INTERFACE)
target_include_directories(ccbench_masstree INTERFACE "${masstree_SOURCE_DIR}")
target_link_libraries(ccbench_masstree INTERFACE "${_masstree_archive}")
add_dependencies(ccbench_masstree masstree_build)
add_library(ccbench::masstree ALIAS ccbench_masstree)

# --- mimalloc --------------------------------------------------------------
#
# mimalloc is a regular CMake project; FetchContent_MakeAvailable drops it
# straight into the build graph and gives us the upstream
# `mimalloc-static` target. We alias it so the rest of the tree keeps
# linking against ccbench::mimalloc unchanged.
#
# Note: we keep the same commit (v2.3.2) the old submodule was pinned to —
# bumping the allocator version is out of scope for issue #98.

set(MI_BUILD_STATIC ON CACHE BOOL "" FORCE)
set(MI_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(MI_BUILD_OBJECT OFF CACHE BOOL "" FORCE)
set(MI_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(MI_OVERRIDE OFF CACHE BOOL "" FORCE)

FetchContent_Declare(
mimalloc
GIT_REPOSITORY "${CCBENCH_MIMALLOC_REPO}"
GIT_TAG "${CCBENCH_MIMALLOC_TAG}"
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(mimalloc)

# Upstream exports `mimalloc-static`; expose it under ccbench:: so callers
# don't have to know which upstream name to use.
add_library(ccbench::mimalloc ALIAS mimalloc-static)

# --- googletest ------------------------------------------------------------
#
# Standard FetchContent + MakeAvailable. The googletest CMake project
# exports `GTest::gtest` / `GTest::gtest_main` targets that the test
# subdirectories (currently only cc/ss2pl/test) link against directly.

set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
# Match MSVC's runtime to the rest of the build — no-op on Linux but
# keeps the project portable if anyone ever builds tests on Windows.
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

FetchContent_Declare(
googletest
GIT_REPOSITORY "${CCBENCH_GOOGLETEST_REPO}"
GIT_TAG "${CCBENCH_GOOGLETEST_TAG}"
GIT_SHALLOW FALSE # SHA pin
)
FetchContent_MakeAvailable(googletest)
30 changes: 17 additions & 13 deletions include/masstree_wrapper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
// フォーマッターを利用すると,辞書順のために下記2行が入れ替わる.
// しかし,依存関係があるため,config -> compiler の順にしなければ
// 大量のエラーが出てしまう. そのため,改行を防ぐため空行を空けている
#include "../third_party/masstree/config.h"

#include "../third_party/masstree/compiler.hh"

#include "../third_party/masstree/kvthread.hh"
#include "../third_party/masstree/masstree.hh"
#include "../third_party/masstree/masstree_insert.hh"
#include "../third_party/masstree/masstree_print.hh"
#include "../third_party/masstree/masstree_remove.hh"
#include "../third_party/masstree/masstree_scan.hh"
#include "../third_party/masstree/masstree_stats.hh"
#include "../third_party/masstree/masstree_tcursor.hh"
#include "../third_party/masstree/string.hh"
//
// masstree のヘッダは ccbench::masstree (cmake/ThirdParty.cmake) の
// INTERFACE_INCLUDE_DIRECTORIES から angle-bracket 形式で引き当てる。
// FetchContent によりソースは build/_deps/masstree-src/ に置かれる。
#include <config.h>

#include <compiler.hh>

#include <kvthread.hh>
#include <masstree.hh>
#include <masstree_insert.hh>
#include <masstree_print.hh>
#include <masstree_remove.hh>
#include <masstree_scan.hh>
#include <masstree_stats.hh>
#include <masstree_tcursor.hh>
#include <string.hh>

#include "atomic_wrapper.hh"
#include "debug.hh"
Expand Down
1 change: 0 additions & 1 deletion third_party/googletest
Submodule googletest deleted from f8d7d7
1 change: 0 additions & 1 deletion third_party/masstree
Submodule masstree deleted from b3c5d0
1 change: 0 additions & 1 deletion third_party/mimalloc
Submodule mimalloc deleted from 02a2f5
Loading