Skip to content

Commit

Permalink
Merge pull request #278 from alex-sparus/immer-archive
Browse files Browse the repository at this point in the history
Immer persist
  • Loading branch information
arximboldi authored Sep 2, 2024
2 parents d3860a6 + 646315e commit d8d5e5d
Show file tree
Hide file tree
Showing 176 changed files with 15,757 additions and 1,097 deletions.
117 changes: 61 additions & 56 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@

cmake_minimum_required(VERSION 3.5.1)
cmake_policy(SET CMP0048 NEW) # enable project VERSION
cmake_policy(SET CMP0056 NEW) # honor link flags in try_compile()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

project(immer VERSION 0.8.0)

if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-extended-offsetof -Wno-c++17-extensions -Wno-c++1z-extensions -Wno-unknown-warning-option -Wno-type-limits")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-extended-offsetof -Wno-c++17-extensions -Wno-c++1z-extensions -Wno-unknown-warning-option -Wno-type-limits"
)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
set(CMAKE_CXX_EXTENSIONS off)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
endif()

include(GNUInstallDirs)
include(ImmerUtils)

# Options
# =======
# Options
# =======

option(ENABLE_ASAN "compile with address sanitizer enabled")
option(ENABLE_MSAN "compile with memory sanitizer enabled")
Expand All @@ -36,37 +37,40 @@ option(ENABLE_GUILE "enable building guile module" off)
option(ENABLE_BOOST_COROUTINE "run benchmarks with boost coroutine" off)

option(immer_BUILD_TESTS "Build tests" ON)
option(immer_BUILD_PERSIST_TESTS "Build experimental persist tests" off)
option(immer_BUILD_EXAMPLES "Build examples" ON)
option(immer_BUILD_DOCS "Build docs" ON)
option(immer_BUILD_EXTRAS "Build extras" ON)
option(immer_INSTALL_FUZZERS "Install fuzzers" off)

set(CXX_STANDARD 14 CACHE STRING "c++ standard number")
set(CXX_STANDARD
14
CACHE STRING "c++ standard number")

set(CMAKE_CXX_STANDARD ${CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED on)

if (ENABLE_ASAN)
if(ENABLE_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
if (ENABLE_LSAN)
if(ENABLE_LSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
endif()
if (ENABLE_UBSAN)
if(ENABLE_UBSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
if (ENABLE_MSAN)
if(ENABLE_MSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory")
endif()

if (NOT MSVC AND NOT DISABLE_WERROR)
if(NOT MSVC AND NOT DISABLE_WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()

# Dependencies
# ============
# Dependencies
# ============

if (ENABLE_BOOST_COROUTINE)
if(ENABLE_BOOST_COROUTINE)
set(immer_boost_components coroutine)
endif()

Expand All @@ -75,27 +79,28 @@ find_package(BoehmGC)
find_package(Boost 1.56 COMPONENTS ${immer_boost_components})

find_program(CCACHE ccache)
if (CCACHE)
if(CCACHE)
message(STATUS "Using ccache: ${CCACHE}")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_CXX_LINKER_LAUNCHER ${CCACHE})
else()
message(STATUS "Could not find ccache")
endif()

if (NOT BOEHM_GC_FOUND)
if(NOT BOEHM_GC_FOUND)
set(BOEHM_GC_LIBRARIES "")
endif()

# Targets
# =======
# Targets
# =======

# the library
add_library(immer INTERFACE)
target_include_directories(immer INTERFACE
$<BUILD_INTERFACE:${immer_BINARY_DIR}/>
$<BUILD_INTERFACE:${immer_SOURCE_DIR}/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_include_directories(
immer
INTERFACE $<BUILD_INTERFACE:${immer_BINARY_DIR}/>
$<BUILD_INTERFACE:${immer_SOURCE_DIR}/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
install(TARGETS immer EXPORT ImmerConfig)
install(EXPORT ImmerConfig DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Immer")
install(DIRECTORY immer DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
Expand All @@ -104,62 +109,62 @@ include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ImmerConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion )
COMPATIBILITY SameMajorVersion)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ImmerConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Immer" )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ImmerConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Immer")

# development target to be used in tests, examples, benchmarks...
immer_canonicalize_cmake_booleans(
DISABLE_FREE_LIST
DISABLE_THREAD_SAFETY
CHECK_SLOW_TESTS)
immer_canonicalize_cmake_booleans(DISABLE_FREE_LIST DISABLE_THREAD_SAFETY
CHECK_SLOW_TESTS)
add_library(immer-dev INTERFACE)
target_include_directories(immer-dev SYSTEM INTERFACE
${Boost_INCLUDE_DIR}
${BOEHM_GC_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/tools/include)
target_link_libraries(immer-dev INTERFACE
immer
${BOEHM_GC_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
target_compile_definitions(immer-dev INTERFACE
-DIMMER_CXX_STANDARD=${CXX_STANDARD}
-DIMMER_HAS_LIBGC=1
-DIMMER_NO_FREE_LIST=${DISABLE_FREE_LIST}
-DIMMER_NO_THREAD_SAFETY=${DISABLE_THREAD_SAFETY}
-DIMMER_SLOW_TESTS=${CHECK_SLOW_TESTS}
-DFMT_HEADER_ONLY=1)
if (ENABLE_COVERAGE)
target_include_directories(
immer-dev SYSTEM INTERFACE ${Boost_INCLUDE_DIR} ${BOEHM_GC_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/tools/include)
target_link_libraries(immer-dev INTERFACE immer ${BOEHM_GC_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
target_compile_definitions(
immer-dev
INTERFACE -DIMMER_CXX_STANDARD=${CXX_STANDARD}
-DIMMER_HAS_LIBGC=1
-DIMMER_NO_FREE_LIST=${DISABLE_FREE_LIST}
-DIMMER_NO_THREAD_SAFETY=${DISABLE_THREAD_SAFETY}
-DIMMER_SLOW_TESTS=${CHECK_SLOW_TESTS}
-DFMT_HEADER_ONLY=1)
if(ENABLE_COVERAGE)
target_compile_options(immer-dev INTERFACE "--coverage")
target_link_libraries(immer-dev INTERFACE "--coverage")
endif()

# Testing
# =======
# Testing
# =======

if (immer_BUILD_TESTS OR immer_BUILD_EXAMPLES OR immer_BUILD_EXTRAS)
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Build and run all the tests and examples.")
if(immer_BUILD_TESTS
OR immer_BUILD_EXAMPLES
OR immer_BUILD_EXTRAS)
add_custom_target(
check
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Build and run all the tests and examples.")
endif()

if (immer_BUILD_TESTS)
if(immer_BUILD_TESTS)
enable_testing()

add_subdirectory(test)
add_subdirectory(benchmark)
endif()

if (immer_BUILD_EXAMPLES)
if(immer_BUILD_EXAMPLES)
add_subdirectory(example)
endif()

if (immer_BUILD_DOCS)
if(immer_BUILD_DOCS)
add_subdirectory(doc)
endif()

if (immer_BUILD_EXTRAS)
if(immer_BUILD_EXTRAS)
add_subdirectory(extra/fuzzer)
add_subdirectory(extra/python)
add_subdirectory(extra/guile)
Expand Down
106 changes: 57 additions & 49 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@

# Config
# ======
# Config
# ======

option(CHECK_BENCHMARKS "Run benchmarks on check target" off)
option(BENCHMARK_DISABLE_GC "Disable gc during a measurement")

set(BENCHMARK_PARAM "N:1000" CACHE STRING "Benchmark parameters")
set(BENCHMARK_SAMPLES "20" CACHE STRING "Benchmark samples")
set(BENCHMARK_PARAM
"N:1000"
CACHE STRING "Benchmark parameters")
set(BENCHMARK_SAMPLES
"20"
CACHE STRING "Benchmark samples")

# Dependencies
# ============
# Dependencies
# ============

find_package(RRB)

if (NOT RRB_FOUND)
if(NOT RRB_FOUND)
message(STATUS "Disabling benchmarks")
return()
endif()

# These are expected to be in the include path, the nix-shell
# environment installs them:
# These are expected to be in the include path, the nix-shell environment
# installs them:
#
# https://github.com/marcusz/steady
# https://github.com/deepsea-inria/chunkedseq.git
# https://github.com/rsms/immutable-cpp.git
# https://github.com/marcusz/steady
# https://github.com/deepsea-inria/chunkedseq.git
# https://github.com/rsms/immutable-cpp.git

# Targets
# =======
# Targets
# =======

add_custom_target(benchmarks
COMMENT "Build all benchmarks.")
add_custom_target(benchmarks COMMENT "Build all benchmarks.")

execute_process(
COMMAND git log -1 --format=%h
Expand All @@ -43,7 +45,7 @@ execute_process(
OUTPUT_VARIABLE immer_git_status
OUTPUT_STRIP_TRAILING_WHITESPACE)

if (NOT immer_git_status STREQUAL "")
if(NOT immer_git_status STREQUAL "")
set(immer_git_commit_hash "${immer_git_commit_hash}+")
endif()

Expand All @@ -52,7 +54,8 @@ site_name(immer_hostname)
get_filename_component(immer_compiler_name "${CMAKE_CXX_COMPILER}" NAME)

set(immer_benchmark_report_base_dir "${CMAKE_SOURCE_DIR}/reports")
set(immer_benchmark_report_dir "${immer_benchmark_report_base_dir}/report_\
set(immer_benchmark_report_dir
"${immer_benchmark_report_base_dir}/report_\
${immer_git_commit_hash}_\
${immer_hostname}_\
${immer_compiler_name}_\
Expand All @@ -75,9 +78,9 @@ if(CHECK_BENCHMARKS)
add_dependencies(check benchmarks)
endif()

add_custom_target(benchmark-report-dir
COMMAND ${CMAKE_COMMAND}
-E make_directory ${immer_benchmark_report_dir})
add_custom_target(
benchmark-report-dir COMMAND ${CMAKE_COMMAND} -E make_directory
${immer_benchmark_report_dir})

file(GLOB_RECURSE immer_benchmarks "*.cpp")
foreach(_file IN LISTS immer_benchmarks)
Expand All @@ -87,36 +90,41 @@ foreach(_file IN LISTS immer_benchmarks)
add_dependencies(benchmarks ${_target})
add_dependencies(${_target} benchmark-report-dir)
target_compile_options(${_target} PUBLIC -Wno-unused-function)
target_compile_definitions(${_target} PUBLIC
NONIUS_RUNNER
IMMER_BENCHMARK_LIBRRB=1
IMMER_BENCHMARK_STEADY=1
IMMER_BENCHMARK_EXPERIMENTAL=0
IMMER_BENCHMARK_DISABLE_GC=${BENCHMARK_DISABLE_GC}
IMMER_BENCHMARK_BOOST_COROUTINE=${ENABLE_BOOST_COROUTINE})
target_link_libraries(${_target} PUBLIC
immer-dev
${RRB_LIBRARIES})
target_include_directories(${_target} SYSTEM PUBLIC
${RRB_INCLUDE_DIR})
target_compile_definitions(
${_target}
PUBLIC NONIUS_RUNNER
IMMER_BENCHMARK_LIBRRB=1
IMMER_BENCHMARK_STEADY=1
IMMER_BENCHMARK_EXPERIMENTAL=0
IMMER_BENCHMARK_DISABLE_GC=${BENCHMARK_DISABLE_GC}
IMMER_BENCHMARK_BOOST_COROUTINE=${ENABLE_BOOST_COROUTINE})
target_link_libraries(${_target} PUBLIC immer-dev ${RRB_LIBRARIES})
target_include_directories(${_target} SYSTEM PUBLIC ${RRB_INCLUDE_DIR})
if(CHECK_BENCHMARKS)
add_test("benchmark/${_output}" "${CMAKE_SOURCE_DIR}/tools/with-tee.bash"
add_test(
"benchmark/${_output}"
"${CMAKE_SOURCE_DIR}/tools/with-tee.bash"
${immer_benchmark_report_dir}/${_target}.out
"${CMAKE_CURRENT_BINARY_DIR}/${_output}" -v
-t ${_target}
-r html
-s ${BENCHMARK_SAMPLES}
-p ${BENCHMARK_PARAM}
-o ${immer_benchmark_report_dir}/${_target}.html)
"${CMAKE_CURRENT_BINARY_DIR}/${_output}"
-v
-t
${_target}
-r
html
-s
${BENCHMARK_SAMPLES}
-p
${BENCHMARK_PARAM}
-o
${immer_benchmark_report_dir}/${_target}.html)
endif()
endforeach()

add_custom_target(upload-benchmark-reports
COMMAND
rsync -av ${immer_benchmark_report_base_dir}
[email protected]:/var/lib/syncthing/public/misc/immer/)
add_custom_target(
upload-benchmark-reports
COMMAND rsync -av ${immer_benchmark_report_base_dir}
[email protected]:/var/lib/syncthing/public/misc/immer/)

add_custom_target(copy-benchmark-reports
COMMAND
rsync -av ${immer_benchmark_report_base_dir}
~/public/misc/immer/)
add_custom_target(
copy-benchmark-reports COMMAND rsync -av ${immer_benchmark_report_base_dir}
~/public/misc/immer/)
Loading

0 comments on commit d8d5e5d

Please sign in to comment.