diff --git a/build-support/compile_time.sh b/build-support/compile_time.sh new file mode 100755 index 00000000000..99c24803653 --- /dev/null +++ b/build-support/compile_time.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# +# Copyright 2021-present StarRocks, Inc. All rights reserved. +# +# 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 +# +# https://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. +# +# Modified from hyrise project + +CURR_DIR=$(dirname "$0") +PARENT_DIR=$(cd "$CURR_DIR/.."; pwd) +output="$PARENT_DIR"/compile_times.txt + +start=$(date +%s) +"$@" +end=$(date +%s) +runtime=$((end-start)) +echo "$runtime ${*: -1}" >> "$output" diff --git a/build.sh b/build.sh index 0e092471b2f..6726a9446db 100755 --- a/build.sh +++ b/build.sh @@ -93,6 +93,9 @@ Usage: $0 --with-clang-tidy build Backend with clang-tidy(default without clang-tidy) --without-java-ext build Backend without java-extensions(default with java-extensions) -j build Backend parallel + --output-compile-time + save a list of the compile time for every C++ file in ${ROOT}/compile_times.txt. + Turning this option on automatically disables ccache. Eg. $0 build all @@ -122,6 +125,7 @@ OPTS=$(getopt \ -l 'without-java-ext' \ -l 'use-staros' \ -l 'enable-shared-data' \ + -l 'output-compile-time' \ -o 'j:' \ -l 'help' \ -- "$@") @@ -143,6 +147,7 @@ WITH_BENCH=OFF WITH_CLANG_TIDY=OFF USE_STAROS=OFF BUILD_JAVA_EXT=ON +OUTPUT_COMPILE_TIME=OFF MSG="" MSG_FE="Frontend" MSG_DPP="Spark Dpp application" @@ -160,7 +165,7 @@ fi if [[ -z ${JEMALLOC_DEBUG} ]]; then JEMALLOC_DEBUG=OFF fi -if [[ -z ${CCACHE} ]]; then +if [[ -z ${CCACHE} ]] && [[ -x "$(command -v ccache)" ]]; then CCACHE=ccache fi @@ -238,6 +243,7 @@ else --with-bench) WITH_BENCH=ON; shift ;; --with-clang-tidy) WITH_CLANG_TIDY=ON; shift ;; --without-java-ext) BUILD_JAVA_EXT=OFF; shift ;; + --output-compile-time) OUTPUT_COMPILE_TIME=ON; shift ;; -h) HELP=1; shift ;; --help) HELP=1; shift ;; -j) PARALLEL=$2; shift 2 ;; @@ -278,6 +284,7 @@ echo "Get params: WITH_CACHELIB -- $WITH_CACHELIB ENABLE_FAULT_INJECTION -- $ENABLE_FAULT_INJECTION BUILD_JAVA_EXT -- $BUILD_JAVA_EXT + OUTPUT_COMPILE_TIME -- $OUTPUT_COMPILE_TIME " check_tool() @@ -348,16 +355,23 @@ if [ ${BUILD_BE} -eq 1 ] ; then fi export STARLET_INSTALL_DIR fi + + if [ "${OUTPUT_COMPILE_TIME}" == "ON" ]; then + rm -f ${ROOT}/compile_times.txt + CXX_COMPILER_LAUNCHER=${ROOT}/build-support/compile_time.sh + else + CXX_COMPILER_LAUNCHER=${CCACHE} + fi ${CMAKE_CMD} -G "${CMAKE_GENERATOR}" \ -DSTARROCKS_THIRDPARTY=${STARROCKS_THIRDPARTY} \ -DSTARROCKS_HOME=${STARROCKS_HOME} \ -DSTARLET_INSTALL_DIR=${STARLET_INSTALL_DIR} \ - -DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE} \ + -DCMAKE_CXX_COMPILER_LAUNCHER=${CXX_COMPILER_LAUNCHER} \ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ -DMAKE_TEST=OFF -DWITH_GCOV=${WITH_GCOV} \ -DUSE_AVX2=$USE_AVX2 -DUSE_AVX512=$USE_AVX512 -DUSE_SSE4_2=$USE_SSE4_2 \ - -DJEMALLOC_DEBUG=$JEMALLOC_DEBUG \ + -DJEMALLOC_DEBUG=$JEMALLOC_DEBUG \ -DENABLE_QUERY_DEBUG_TRACE=$ENABLE_QUERY_DEBUG_TRACE \ -DWITH_BENCH=${WITH_BENCH} \ -DWITH_CLANG_TIDY=${WITH_CLANG_TIDY} \