From b7b87fbf497ffca25e91d6a001473291e49bba97 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Mon, 10 Jan 2022 09:29:55 -0500 Subject: [PATCH] Add build-time publish step to cpu build script (#9927) Follow on to #9631. This copies the generated BuildMetrics.html to the ci/cpu/build.sh to make it available for the Jenkins publishHtml publisher. Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Karthikeyan (https://github.com/karthikeyann) - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/cudf/pull/9927 --- build.sh | 43 +++++++++++++++++++++++++++------- ci/cpu/build.sh | 8 +++++++ ci/gpu/build.sh | 6 ++--- conda/recipes/libcudf/build.sh | 2 +- cpp/scripts/sort_ninja_log.py | 33 ++++++++++++++++++++++---- 5 files changed, 75 insertions(+), 17 deletions(-) diff --git a/build.sh b/build.sh index adf6e220744..f5a59b6edcf 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. # cuDF build script @@ -17,7 +17,7 @@ ARGS=$* # script, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean libcudf cudf dask_cudf benchmarks tests libcudf_kafka cudf_kafka custreamz -v -g -n -l --allgpuarch --disable_nvtx --show_depr_warn --ptds -h" +VALIDARGS="clean libcudf cudf dask_cudf benchmarks tests libcudf_kafka cudf_kafka custreamz -v -g -n -l --allgpuarch --disable_nvtx --show_depr_warn --ptds -h --build_metrics --incl_cache_stats" HELP="$0 [clean] [libcudf] [cudf] [dask_cudf] [benchmarks] [tests] [libcudf_kafka] [cudf_kafka] [custreamz] [-v] [-g] [-n] [-h] [-l] [--cmake-args=\\\"\\\"] clean - remove all existing build artifacts and configuration (start over) @@ -37,6 +37,8 @@ HELP="$0 [clean] [libcudf] [cudf] [dask_cudf] [benchmarks] [tests] [libcudf_kafk --disable_nvtx - disable inserting NVTX profiling ranges --show_depr_warn - show cmake deprecation warnings --ptds - enable per-thread default stream + --build_metrics - generate build metrics report for libcudf + --incl_cache_stats - include cache statistics in build metrics report --cmake-args=\\\"\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument) -h | --h[elp] - print this text @@ -61,6 +63,8 @@ BUILD_NVTX=ON BUILD_TESTS=OFF BUILD_DISABLE_DEPRECATION_WARNING=ON BUILD_PER_THREAD_DEFAULT_STREAM=OFF +BUILD_REPORT_METRICS=OFF +BUILD_REPORT_INCL_CACHE_STATS=OFF # Set defaults for vars that may not have been defined externally # FIXME: if INSTALL_PREFIX is not set, check PREFIX, then check @@ -144,6 +148,14 @@ fi if hasArg --ptds; then BUILD_PER_THREAD_DEFAULT_STREAM=ON fi +if hasArg --build_metrics; then + BUILD_REPORT_METRICS=ON +fi + +if hasArg --incl_cache_stats; then + BUILD_REPORT_INCL_CACHE_STATS=ON +fi + # If clean given, run it prior to any other steps if hasArg clean; then @@ -174,8 +186,11 @@ if buildAll || hasArg libcudf; then # get the current count before the compile starts FILES_IN_CCACHE="" - if [ -x "$(command -v ccache)" ]; then + if [[ "$BUILD_REPORT_INCL_CACHE_STATS"=="ON" && -x "$(command -v ccache)" ]]; then FILES_IN_CCACHE=$(ccache -s | grep "files in cache") + echo "$FILES_IN_CCACHE" + # zero the ccache statistics + ccache -z fi cmake -S $REPODIR/cpp -B ${LIB_BUILD_DIR} \ @@ -197,12 +212,24 @@ if buildAll || hasArg libcudf; then compile_total=$(( compile_end - compile_start )) # Record build times - if [[ -f "${LIB_BUILD_DIR}/.ninja_log" ]]; then - echo "Formatting build times" + if [[ "$BUILD_REPORT_METRICS"=="ON" && -f "${LIB_BUILD_DIR}/.ninja_log" ]]; then + echo "Formatting build metrics" python ${REPODIR}/cpp/scripts/sort_ninja_log.py ${LIB_BUILD_DIR}/.ninja_log --fmt xml > ${LIB_BUILD_DIR}/ninja_log.xml - message="$FILES_IN_CCACHE

$PARALLEL_LEVEL parallel build time is $compile_total seconds" - echo "$message" - python ${REPODIR}/cpp/scripts/sort_ninja_log.py ${LIB_BUILD_DIR}/.ninja_log --fmt html --msg "$message" > ${LIB_BUILD_DIR}/ninja_log.html + MSG="

" + # get some ccache stats after the compile + if [[ "$BUILD_REPORT_INCL_CACHE_STATS"=="ON" && -x "$(command -v ccache)" ]]; then + MSG="${MSG}
$FILES_IN_CCACHE" + HIT_RATE=$(ccache -s | grep "cache hit rate") + MSG="${MSG}
${HIT_RATE}" + fi + MSG="${MSG}
parallel setting: $PARALLEL_LEVEL" + MSG="${MSG}
parallel build time: $compile_total seconds" + if [[ -f "${LIB_BUILD_DIR}/libcudf.so" ]]; then + LIBCUDF_FS=$(ls -lh ${LIB_BUILD_DIR}/libcudf.so | awk '{print $5}') + MSG="${MSG}
libcudf.so size: $LIBCUDF_FS" + fi + echo "$MSG" + python ${REPODIR}/cpp/scripts/sort_ninja_log.py ${LIB_BUILD_DIR}/.ninja_log --fmt html --msg "$MSG" > ${LIB_BUILD_DIR}/ninja_log.html fi if [[ ${INSTALL_TARGET} != "" ]]; then diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index 00dffa57683..f23296038f2 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -78,6 +78,14 @@ if [ "$BUILD_LIBCUDF" == '1' ]; then mkdir -p ${CONDA_BLD_DIR}/libcudf/work cp -r ${CONDA_BLD_DIR}/work/* ${CONDA_BLD_DIR}/libcudf/work + # Copy libcudf build metrics results + LIBCUDF_BUILD_DIR=$CONDA_BLD_DIR/libcudf/work/cpp/build + echo "Checking for build metrics log $LIBCUDF_BUILD_DIR/ninja_log.html" + if [[ -f "$LIBCUDF_BUILD_DIR/ninja_log.html" ]]; then + gpuci_logger "Copying build metrics results" + mkdir -p "$WORKSPACE/build-metrics" + cp "$LIBCUDF_BUILD_DIR/ninja_log.html" "$WORKSPACE/build-metrics/BuildMetrics.html" + fi gpuci_logger "Build conda pkg for libcudf_kafka" gpuci_conda_retry build --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/libcudf_kafka $CONDA_BUILD_ARGS diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 4ac2fe79bf6..059e359e4e9 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -181,12 +181,10 @@ else done # Copy libcudf build time results - echo "Checking for build time log $LIB_BUILD_DIR/ninja_log.html" - if [[ -f "$LIB_BUILD_DIR/ninja_log.html" ]]; then + echo "Checking for build time log $LIB_BUILD_DIR/ninja_log.xml" + if [[ -f "$LIB_BUILD_DIR/ninja_log.xml" ]]; then gpuci_logger "Copying build time results" cp "$LIB_BUILD_DIR/ninja_log.xml" "$WORKSPACE/test-results/buildtimes-junit.xml" - mkdir -p "$WORKSPACE/build-metrics" - cp "$LIB_BUILD_DIR/ninja_log.html" "$WORKSPACE/build-metrics/BuildMetrics.html" fi ################################################################################ diff --git a/conda/recipes/libcudf/build.sh b/conda/recipes/libcudf/build.sh index 703f8dc15c7..c3730b3241a 100644 --- a/conda/recipes/libcudf/build.sh +++ b/conda/recipes/libcudf/build.sh @@ -4,5 +4,5 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then # This assumes the script is executed from the root of the repo directory ./build.sh -v libcudf --allgpuarch --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" else - ./build.sh -v libcudf tests --allgpuarch --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" + ./build.sh -v libcudf tests --allgpuarch --build_metrics --incl_cache_stats --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" fi diff --git a/cpp/scripts/sort_ninja_log.py b/cpp/scripts/sort_ninja_log.py index 5eada13aea2..bac6697da82 100755 --- a/cpp/scripts/sort_ninja_log.py +++ b/cpp/scripts/sort_ninja_log.py @@ -88,21 +88,38 @@ elif output_fmt == "html": # output results in HTML format print("Sorted Ninja Build Times") - print("") + # Note: Jenkins does not support style defined in the html + # https://www.jenkins.io/doc/book/security/configuring-content-security-policy/ print("") if args.msg is not None: print("

", args.msg, "

") print("") print( "", - "", - "", + "", + "", sep="", ) + summary = {"red": 0, "yellow": 0, "green": 0} + red = "bgcolor='#FFBBD0'" + yellow = "bgcolor='#FFFF80'" + green = "bgcolor='#AAFFBD'" for key in sl: result = entries[key] + elapsed = result[0] + color = green + if elapsed > 300000: # 5 minutes + color = red + summary["red"] += 1 + elif elapsed > 120000: # 2 minutes + color = yellow + summary["yellow"] += 1 + else: + summary["green"] += 1 print( - "", sep="", ) + print("
FileCompile time (ms)Size (bytes)
Compile time
(ms)
Size
(bytes)
", + "
", key, "", result[0], @@ -111,6 +128,14 @@ "

") + # include summary table with color legend + print("time > 5 minutes") + print("") + print("2 minutes < time < 5 minutes") + print("") + print("time < 2 minutes") + print("") print("
", summary["red"], "
", summary["yellow"], "
", summary["green"], "
") else: