Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
zclllyybb committed Nov 18, 2024
1 parent 866033f commit 2bc1964
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 25 deletions.
61 changes: 38 additions & 23 deletions be/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ message(STATUS "THIRDPARTY_DIR is ${THIRDPARTY_DIR}")

option(MAKE_TEST "ON for make unit test or OFF for not" OFF)
message(STATUS "make test: ${MAKE_TEST}")
option(BUILD_BENCHMARK "ON for make google benchmark or OFF for not" OFF)
message(STATUS "make benchmark: ${BUILD_BENCHMARK}")

option(WITH_MYSQL "Support access MySQL" ON)

Expand Down Expand Up @@ -568,7 +570,7 @@ if (OS_MACOSX)
)
endif()

if (MAKE_TEST)
if (MAKE_TEST OR BUILD_BENCHMARK)
set(COMMON_THIRDPARTY
${COMMON_THIRDPARTY}
benchmark
Expand Down Expand Up @@ -708,6 +710,11 @@ if (MAKE_TEST)
endif()
endif ()

# use this to avoid some runtime tracker. reuse BE_TEST symbol, no need another.
if (BUILD_BENCHMARK)
add_definitions(-DBE_TEST)
endif()

get_directory_property(COMPILER_FLAGS COMPILE_OPTIONS)
get_directory_property(COMPILER_DEFINES COMPILE_DEFINITIONS)
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}")
Expand Down Expand Up @@ -754,7 +761,7 @@ add_subdirectory(${SRC_DIR}/http)
add_subdirectory(${SRC_DIR}/io)
add_subdirectory(${SRC_DIR}/olap)
add_subdirectory(${SRC_DIR}/runtime)
add_subdirectory(${SRC_DIR}/service)
add_subdirectory(${SRC_DIR}/service) # this include doris_be
add_subdirectory(${SRC_DIR}/udf)
add_subdirectory(${SRC_DIR}/cloud)

Expand All @@ -772,36 +779,44 @@ add_subdirectory(${SRC_DIR}/util)
add_subdirectory(${SRC_DIR}/vec)
add_subdirectory(${SRC_DIR}/pipeline)

# this include doris_be_test
if (MAKE_TEST)
add_subdirectory(${TEST_DIR})
endif ()

add_subdirectory(${COMMON_SRC_DIR}/cpp ${BUILD_DIR}/src/common_cpp)

# Install be
install(DIRECTORY DESTINATION ${OUTPUT_DIR})
install(DIRECTORY DESTINATION ${OUTPUT_DIR}/bin)
install(DIRECTORY DESTINATION ${OUTPUT_DIR}/conf)

install(FILES
${BASE_DIR}/../bin/start_be.sh
${BASE_DIR}/../bin/stop_be.sh
${BASE_DIR}/../tools/jeprof
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
DESTINATION ${OUTPUT_DIR}/bin)

install(FILES
${BASE_DIR}/../conf/be.conf
${BASE_DIR}/../conf/odbcinst.ini
${BASE_DIR}/../conf/asan_suppr.conf
${BASE_DIR}/../conf/lsan_suppr.conf
DESTINATION ${OUTPUT_DIR}/conf)
if(NOT BUILD_BENCHMARK)
# Install be
install(DIRECTORY DESTINATION ${OUTPUT_DIR})
install(DIRECTORY DESTINATION ${OUTPUT_DIR}/bin)
install(DIRECTORY DESTINATION ${OUTPUT_DIR}/conf)

install(FILES
${BASE_DIR}/../bin/start_be.sh
${BASE_DIR}/../bin/stop_be.sh
${BASE_DIR}/../tools/jeprof
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
DESTINATION ${OUTPUT_DIR}/bin)

install(FILES
${BASE_DIR}/../conf/be.conf
${BASE_DIR}/../conf/odbcinst.ini
${BASE_DIR}/../conf/asan_suppr.conf
${BASE_DIR}/../conf/lsan_suppr.conf
DESTINATION ${OUTPUT_DIR}/conf)
endif()

get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS "dir='${dir}'")
endforeach()


if (BUILD_BENCHMARK)
add_executable(benchmark_test ${BASE_DIR}/benchmark/benchmark_main.cpp)
target_link_libraries(benchmark_test ${DORIS_LINK_LIBS})
message(STATUS "Add benchmark to build")
install(TARGETS benchmark_test DESTINATION ${OUTPUT_DIR})
endif()
49 changes: 49 additions & 0 deletions be/benchmark/benchmark_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.h>

#include <string>

#include "vec/columns/column_string.h"
#include "vec/core/block.h"
#include "vec/data_types/data_type.h"
#include "vec/data_types/data_type_string.h"

namespace doris::vectorized {

static void Example1(benchmark::State& state) {
state.PauseTiming();
Block block;
DataTypePtr str_type = std::make_shared<DataTypeString>();
std::vector<std::string> vals {100, "content"};
state.ResumeTiming();

for (auto _ : state) {
auto str_col = ColumnString::create();
for (auto& v : vals) {
str_col->insert_data(v.data(), v.size());
}
block.insert({std::move(str_col), str_type, "col"});
benchmark::DoNotOptimize(block);
}
}
BENCHMARK(Example1);

} // namespace doris::vectorized

BENCHMARK_MAIN();
2 changes: 1 addition & 1 deletion be/src/runtime/memory/jemalloc_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void* doris_realloc(void* p, size_t size) __THROW {
return nullptr;
}

#if USE_MEM_TRACKER
#if defined(USE_MEM_TRACKER) && !defined(BE_TEST)
int64_t old_size = jemalloc_usable_size(p);
CONSUME_THREAD_MEM_TRACKER_BY_HOOK_WITH_FN(
[](size_t size, int64_t old_size) { return jenallocx(size, 0) - old_size; }, size,
Expand Down
2 changes: 1 addition & 1 deletion be/src/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ add_library(Service STATIC ${SRC_FILES})

pch_reuse(Service)

if (${MAKE_TEST} STREQUAL "OFF")
if (${MAKE_TEST} STREQUAL "OFF" AND ${BUILD_BENCHMARK} STREQUAL "OFF")
add_executable(doris_be
doris_main.cpp
)
Expand Down
17 changes: 17 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Usage: $0 <options>
--meta-tool build Backend meta tool. Default OFF.
--cloud build Cloud. Default OFF.
--index-tool build Backend inverted index tool. Default OFF.
--benchmark build Google Benchmark. Default OFF.
--broker build Broker. Default ON.
--spark-dpp build Spark DPP application. Default ON.
--hive-udf build Hive UDF library for Spark Load. Default ON.
Expand All @@ -64,12 +65,14 @@ Usage: $0 <options>
DISABLE_BE_JAVA_EXTENSIONS If set DISABLE_BE_JAVA_EXTENSIONS=ON, we will do not build binary with java-udf,hudi-scanner,jdbc-scanner and so on Default is OFF.
DISABLE_JAVA_CHECK_STYLE If set DISABLE_JAVA_CHECK_STYLE=ON, it will skip style check of java code in FE.
DISABLE_BUILD_AZURE If set DISABLE_BUILD_AZURE=ON, it will not build azure into BE.
Eg.
$0 build all
$0 --be build Backend
$0 --meta-tool build Backend meta tool
$0 --cloud build Cloud
$0 --index-tool build Backend inverted index tool
$0 --benchmark build Google Benchmark of Backend
$0 --fe --clean clean and build Frontend and Spark Dpp application
$0 --fe --be --clean clean and build Frontend, Spark Dpp application and Backend
$0 --spark-dpp build Spark DPP application alone
Expand Down Expand Up @@ -129,6 +132,7 @@ if ! OPTS="$(getopt \
-l 'broker' \
-l 'meta-tool' \
-l 'index-tool' \
-l 'benchmark' \
-l 'spark-dpp' \
-l 'hive-udf' \
-l 'be-java-extensions' \
Expand All @@ -151,6 +155,7 @@ BUILD_CLOUD=0
BUILD_BROKER=0
BUILD_META_TOOL='OFF'
BUILD_INDEX_TOOL='OFF'
BUILD_BENCHMARK='OFF'
BUILD_SPARK_DPP=0
BUILD_BE_JAVA_EXTENSIONS=0
BUILD_HIVE_UDF=0
Expand All @@ -170,6 +175,7 @@ if [[ "$#" == 1 ]]; then
BUILD_BROKER=1
BUILD_META_TOOL='OFF'
BUILD_INDEX_TOOL='OFF'
BUILD_BENCHMARK='OFF'
BUILD_SPARK_DPP=1
BUILD_HIVE_UDF=1
BUILD_BE_JAVA_EXTENSIONS=1
Expand Down Expand Up @@ -205,6 +211,11 @@ else
BUILD_INDEX_TOOL='ON'
shift
;;
--benchmark)
BUILD_BENCHMARK='ON'
BUILD_BE=1 # go into BE cmake building, but benchmark instead of doris_be
shift
;;
--spark-dpp)
BUILD_SPARK_DPP=1
shift
Expand Down Expand Up @@ -446,6 +457,10 @@ if [[ -z "${ENABLE_CACHE_LOCK_DEBUG}" ]]; then
ENABLE_CACHE_LOCK_DEBUG='OFF'
fi

if [[ -z "${BUILD_BENCHMARK}" ]]; then
BUILD_BENCHMARK='OFF'
fi

if [[ -z "${RECORD_COMPILER_SWITCHES}" ]]; then
RECORD_COMPILER_SWITCHES='OFF'
fi
Expand Down Expand Up @@ -476,6 +491,7 @@ echo "Get params:
BUILD_BROKER -- ${BUILD_BROKER}
BUILD_META_TOOL -- ${BUILD_META_TOOL}
BUILD_INDEX_TOOL -- ${BUILD_INDEX_TOOL}
BUILD_BENCHMARK -- ${BUILD_BENCHMARK}
BUILD_SPARK_DPP -- ${BUILD_SPARK_DPP}
BUILD_BE_JAVA_EXTENSIONS -- ${BUILD_BE_JAVA_EXTENSIONS}
BUILD_HIVE_UDF -- ${BUILD_HIVE_UDF}
Expand Down Expand Up @@ -581,6 +597,7 @@ if [[ "${BUILD_BE}" -eq 1 ]]; then
-DENABLE_INJECTION_POINT="${ENABLE_INJECTION_POINT}" \
-DENABLE_CACHE_LOCK_DEBUG="${ENABLE_CACHE_LOCK_DEBUG}" \
-DMAKE_TEST=OFF \
-DBUILD_BENCHMARK="${BUILD_BENCHMARK}" \
-DBUILD_FS_BENCHMARK="${BUILD_FS_BENCHMARK}" \
${CMAKE_USE_CCACHE:+${CMAKE_USE_CCACHE}} \
-DWITH_MYSQL="${WITH_MYSQL}" \
Expand Down

0 comments on commit 2bc1964

Please sign in to comment.