Skip to content
Open
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
48 changes: 35 additions & 13 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,26 @@ endif()

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

if(PAIMON_BUILD_TESTS OR PAIMON_BUILD_BENCHMARKS)
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 Down Expand Up @@ -388,15 +409,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 +417,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 +449,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 +493,4 @@ add_subdirectory(src/paimon/global_index/lucene)
add_subdirectory(src/paimon/testing/mock)
add_subdirectory(src/paimon/testing/utils)
add_subdirectory(test/inte)
add_subdirectory(benchmark)
Comment thread
lucasfang marked this conversation as resolved.
74 changes: 74 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# 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}
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
${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();
89 changes: 89 additions & 0 deletions benchmark/benchmark_helpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* 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_helpers.h"

#include <iostream>

#include "benchmark/benchmark.h"

namespace paimon::benchmark {

bool BenchmarkHelpers::ValidateFileFormatOrSkip(::benchmark::State& state,
const std::string& file_format, bool is_supported,
SkipFn skip) {
if (!is_supported) {
skip(state, "file format is not supported in this build: " + file_format);
return false;
}
return true;
}

bool BenchmarkHelpers::ValidateSourcePresenceOrSkip(::benchmark::State& state,
const std::string& source_path,
const std::string& message, SkipFn skip) {
if (source_path.empty()) {
skip(state, message);
return false;
}
return true;
}

bool BenchmarkHelpers::ValidateSourceSupportOrSkip(::benchmark::State& state,
const std::string& source_format,
bool is_supported, SkipFn skip) {
if (!is_supported) {
skip(state,
"source data mode requires reader support in this build for format: " + source_format);
return false;
}
return true;
}

bool BenchmarkHelpers::ValidatePrefetchParallelOrSkip(::benchmark::State& state,
int32_t prefetch_parallel_num, SkipFn skip) {
if (prefetch_parallel_num <= 0) {
skip(state, "prefetch_parallel must be greater than 0");
return false;
}
return true;
}

int64_t BenchmarkHelpers::RunReadIterations(::benchmark::State& state,
const ReadOnceFn& read_once) {
int64_t rows_read = 0;
for (auto _ : state) {
rows_read = read_once();
}
return rows_read;
}

bool BenchmarkHelpers::TryRunExternalReadMode(::benchmark::State& state,
const std::string& benchmark_name,
const std::string& external_table_path,
const ReadOnceFn& read_once) {
if (external_table_path.empty()) {
return false;
}

std::cout << "[benchmark][" << benchmark_name << "] external_table_path=" << external_table_path
<< std::endl;
const int64_t rows_read = RunReadIterations(state, read_once);
state.SetItemsProcessed(state.iterations() * rows_read);
return true;
}

} // namespace paimon::benchmark
Loading
Loading