Skip to content
Merged
55 changes: 40 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(PAIMON_BUILD_STATIC "Build static library" ON)
option(PAIMON_BUILD_SHARED "Build shared library" ON)
option(PAIMON_BUILD_TESTS "Build tests" OFF)
option(PAIMON_BUILD_BENCHMARKS "Build benchmarks" OFF)
option(PAIMON_USE_ASAN "Use Address Sanitizer" OFF)
option(PAIMON_USE_UBSAN "Use Undefined Behavior Sanitizer" OFF)
option(PAIMON_USE_CXX11_ABI "Use C++11 ABI" ON)
Expand Down Expand Up @@ -354,6 +355,29 @@ endif()

set(ENV{PAIMON_TEST_DATA} "${CMAKE_SOURCE_DIR}/test/test_data")

if(PAIMON_BUILD_TESTS OR PAIMON_BUILD_BENCHMARKS)
resolve_dependency(GTest)
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})

paimon_link_libraries_whole_archive(PAIMON_LOCAL_FILE_SYSTEM_STATIC_LINK_LIBS
paimon_local_file_system_static)
paimon_link_libraries_no_as_needed(PAIMON_LOCAL_FILE_SYSTEM_SHARED_LINK_LIBS
paimon_local_file_system_shared)
paimon_link_libraries_whole_archive(PAIMON_BLOB_FILE_FORMAT_STATIC_LINK_LIBS
paimon_blob_file_format_static)
paimon_link_libraries_whole_archive(PAIMON_PARQUET_FILE_FORMAT_STATIC_LINK_LIBS
paimon_parquet_file_format_static)

if(PAIMON_ENABLE_ORC)
paimon_link_libraries_whole_archive(PAIMON_ORC_FILE_FORMAT_STATIC_LINK_LIBS
paimon_orc_file_format_static)
endif()
if(PAIMON_ENABLE_AVRO)
paimon_link_libraries_whole_archive(PAIMON_AVRO_FILE_FORMAT_STATIC_LINK_LIBS
paimon_avro_file_format_static)
endif()
endif()

if(PAIMON_BUILD_TESTS)
if(NOT PAIMON_ENABLE_ORC)
message(FATAL_ERROR "PAIMON_ENABLE_ORC must be enabled if PAIMON_BUILD_TESTS is enable"
Expand All @@ -365,7 +389,6 @@ if(PAIMON_BUILD_TESTS)
endif()
# Adding unit tests part of the "paimon" portion of the test suite
add_custom_target(paimon-tests)
resolve_dependency(GTest)

add_custom_target(unittest
ctest
Expand All @@ -375,7 +398,6 @@ if(PAIMON_BUILD_TESTS)
--output-on-failure)
add_dependencies(unittest paimon-tests)

include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
include_directories("${CMAKE_SOURCE_DIR}/test/")

paimon_link_libraries_whole_archive(
Expand All @@ -388,15 +410,6 @@ if(PAIMON_BUILD_TESTS)
TEST_PLUGIN_LINK_LIBS paimon_parquet_file_format_shared
paimon_blob_file_format_shared)
set(TEST_STATIC_LINK_LIBS ${TEST_WHOLE_ARCHIVE_LINK_LIBS} ${TEST_PLUGIN_LINK_LIBS})
paimon_link_libraries_whole_archive(PAIMON_LOCAL_FILE_SYSTEM_STATIC_LINK_LIBS
paimon_local_file_system_static)
paimon_link_libraries_no_as_needed(PAIMON_LOCAL_FILE_SYSTEM_SHARED_LINK_LIBS
paimon_local_file_system_shared)
paimon_link_libraries_whole_archive(PAIMON_BLOB_FILE_FORMAT_STATIC_LINK_LIBS
paimon_blob_file_format_static)
paimon_link_libraries_whole_archive(PAIMON_PARQUET_FILE_FORMAT_STATIC_LINK_LIBS
paimon_parquet_file_format_static)

if(PAIMON_ENABLE_LANCE)
paimon_link_libraries_whole_archive(PAIMON_LANCE_FILE_FORMAT_STATIC_LINK_LIBS
paimon_lance_file_format_static)
Expand All @@ -405,15 +418,11 @@ if(PAIMON_BUILD_TESTS)
list(APPEND TEST_STATIC_LINK_LIBS ${TEST_PLUGIN_LINK_LIBS})
endif()
if(PAIMON_ENABLE_ORC)
paimon_link_libraries_whole_archive(PAIMON_ORC_FILE_FORMAT_STATIC_LINK_LIBS
paimon_orc_file_format_static)
paimon_link_libraries_no_as_needed(TEST_PLUGIN_LINK_LIBS
paimon_orc_file_format_shared)
list(APPEND TEST_STATIC_LINK_LIBS ${TEST_PLUGIN_LINK_LIBS})
endif()
if(PAIMON_ENABLE_AVRO)
paimon_link_libraries_whole_archive(PAIMON_AVRO_FILE_FORMAT_STATIC_LINK_LIBS
paimon_avro_file_format_static)
paimon_link_libraries_no_as_needed(TEST_PLUGIN_LINK_LIBS
paimon_avro_file_format_shared)
list(APPEND TEST_STATIC_LINK_LIBS ${TEST_PLUGIN_LINK_LIBS})
Expand Down Expand Up @@ -441,6 +450,19 @@ if(PAIMON_BUILD_TESTS)
endif()
endif()

if(PAIMON_BUILD_BENCHMARKS)
add_custom_target(paimon-benchmarks)
add_custom_target(benchmark
ctest
-j4
-L
benchmark
--output-on-failure)
add_dependencies(benchmark paimon-benchmarks)

set(PAIMON_BENCHMARK_LINK_TOOLCHAIN benchmark::benchmark)
endif()

paimon_print_dependency_resolution_summary()

include(CMakePackageConfigHelpers)
Expand Down Expand Up @@ -472,3 +494,6 @@ add_subdirectory(src/paimon/global_index/lucene)
add_subdirectory(src/paimon/testing/mock)
add_subdirectory(src/paimon/testing/utils)
add_subdirectory(test/inte)
if(PAIMON_BUILD_BENCHMARKS)
add_subdirectory(benchmark)
endif()
76 changes: 76 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright 2026-present Alibaba Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if(NOT PAIMON_BUILD_BENCHMARKS AND NOT PAIMON_BUILD_TESTS)
return()
endif()

find_package(Threads REQUIRED)

set(PAIMON_BENCHMARK_STATIC_LINK_LIBS
paimon_shared ${PAIMON_LOCAL_FILE_SYSTEM_SHARED_LINK_LIBS}
${PAIMON_PARQUET_FILE_FORMAT_STATIC_LINK_LIBS}
${PAIMON_BLOB_FILE_FORMAT_STATIC_LINK_LIBS})

if(PAIMON_ENABLE_ORC)
list(APPEND PAIMON_BENCHMARK_STATIC_LINK_LIBS
${PAIMON_ORC_FILE_FORMAT_STATIC_LINK_LIBS})
endif()

if(PAIMON_ENABLE_AVRO)
list(APPEND PAIMON_BENCHMARK_STATIC_LINK_LIBS
${PAIMON_AVRO_FILE_FORMAT_STATIC_LINK_LIBS})
endif()

set(PAIMON_BENCHMARK_PLATFORM_LINK_LIBS)
if(UNIX AND NOT APPLE)
find_library(PAIMON_BENCHMARK_RT_LIBRARY rt)
if(PAIMON_BENCHMARK_RT_LIBRARY)
list(APPEND PAIMON_BENCHMARK_PLATFORM_LINK_LIBS ${PAIMON_BENCHMARK_RT_LIBRARY})
endif()
endif()

if(PAIMON_BUILD_BENCHMARKS)
add_paimon_benchmark(read_write_benchmark
SOURCES
benchmark_helpers.cpp
benchmark_suite.cpp
benchmark_case_write.cpp
benchmark_case_read.cpp
benchmark_case_pk_write.cpp
benchmark_case_mor_read.cpp
read_write_benchmark.cpp
STATIC_LINK_LIBS
arrow
parquet
${PAIMON_BENCHMARK_STATIC_LINK_LIBS}
test_utils_static
Threads::Threads
${CMAKE_DL_LIBS}
${PAIMON_BENCHMARK_PLATFORM_LINK_LIBS}
${PAIMON_BENCHMARK_LINK_TOOLCHAIN}
EXTRA_INCLUDES
${CMAKE_SOURCE_DIR})
endif()

if(PAIMON_BUILD_TESTS)
add_paimon_test(cli_option_parsing_test
SOURCES
cli_option_parsing_test.cpp
EXTRA_INCLUDES
${CMAKE_SOURCE_DIR}
STATIC_LINK_LIBS
paimon_shared
${GTEST_LINK_TOOLCHAIN})
endif()
33 changes: 33 additions & 0 deletions benchmark/benchmark_case_mor_read.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2026-present Alibaba Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "benchmark/benchmark_suite.h"

namespace {

void BM_MOR_Read(::benchmark::State& state) {
paimon::benchmark::RunBMMorRead(state);
}

} // namespace

BENCHMARK(BM_MOR_Read)
->ArgNames({"prefetch_parallel"})
->Unit(benchmark::kMillisecond)
->UseRealTime()
->Args({1})
->Args({2})
->Args({4});
27 changes: 27 additions & 0 deletions benchmark/benchmark_case_pk_write.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2026-present Alibaba Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "benchmark/benchmark_suite.h"

namespace {

void BM_PK_Write(::benchmark::State& state) {
paimon::benchmark::RunBMPkWrite(state);
}

} // namespace

BENCHMARK(BM_PK_Write)->Unit(benchmark::kMillisecond)->UseRealTime();
33 changes: 33 additions & 0 deletions benchmark/benchmark_case_read.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2026-present Alibaba Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "benchmark/benchmark_suite.h"

namespace {

void BM_Read(::benchmark::State& state) {
paimon::benchmark::RunBMRead(state);
}

} // namespace

BENCHMARK(BM_Read)
->ArgNames({"prefetch_parallel"})
->Unit(benchmark::kMillisecond)
->UseRealTime()
->Args({1})
->Args({2})
->Args({4});
27 changes: 27 additions & 0 deletions benchmark/benchmark_case_write.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2026-present Alibaba Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "benchmark/benchmark_suite.h"

namespace {

void BM_Write(::benchmark::State& state) {
paimon::benchmark::RunBMWrite(state);
}

} // namespace

BENCHMARK(BM_Write)->Unit(benchmark::kMillisecond)->UseRealTime();
Loading
Loading