Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utility to format ninja-log build times #9631

Merged
merged 58 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f5479fb
Add utility to format ninja-log build times
davidwendt Nov 8, 2021
644a4af
add copyright header
davidwendt Nov 11, 2021
01c4ebd
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 11, 2021
88d378e
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 12, 2021
461d01c
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 12, 2021
d4bab79
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 15, 2021
49024ca
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 16, 2021
06fa687
make .py executable
davidwendt Nov 16, 2021
639e499
add explicit python invoke
davidwendt Nov 16, 2021
2ed021b
experiment: add clear ccache
davidwendt Nov 16, 2021
a16c167
copy csv to test-results
davidwendt Nov 16, 2021
50d24ea
copy results test 2
davidwendt Nov 16, 2021
5c3cf7b
copy results after gtests
davidwendt Nov 16, 2021
b1265be
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 17, 2021
51cc770
remove unused script
davidwendt Nov 17, 2021
9e3bf53
add ccache file size check
davidwendt Nov 18, 2021
7c08e54
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 18, 2021
21ad4ee
clear ccache experiment
davidwendt Nov 18, 2021
bc626b5
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 19, 2021
6224cba
fix clang-format version check
davidwendt Nov 19, 2021
9be795d
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 19, 2021
405c020
remove temp clear cache
davidwendt Nov 19, 2021
71864e5
add fake error to test-results
davidwendt Nov 22, 2021
7bbcb97
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 22, 2021
292e523
output build times in xml
davidwendt Nov 22, 2021
754b259
errors test
davidwendt Nov 22, 2021
bb8a6de
experiment: modify threshold
davidwendt Nov 23, 2021
9c06d3f
get some baseline build times
davidwendt Nov 23, 2021
e79d240
exper: change thrust calls in opt-iter
davidwendt Nov 24, 2021
8d534bd
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 24, 2021
3da9437
undo exper iter-test changes
davidwendt Nov 29, 2021
3f46cff
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 29, 2021
81dbc60
fix script and remove cache clear
davidwendt Nov 29, 2021
334ae7f
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Nov 30, 2021
f5726ed
move script to cpp/scripts
davidwendt Nov 30, 2021
8590a12
fix top-50 console output
davidwendt Nov 30, 2021
2df62e0
fix merge conflict
davidwendt Dec 1, 2021
fb57dca
add html output to sort script
davidwendt Dec 2, 2021
4ca9b93
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Dec 2, 2021
5ce033a
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Dec 3, 2021
906e234
add build sizes to html output
davidwendt Dec 3, 2021
b66f5b7
remove .csv output
davidwendt Dec 6, 2021
d8d0536
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Dec 7, 2021
ef54f52
use argparse for python script
davidwendt Dec 7, 2021
0d7e838
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Dec 8, 2021
488bcfb
change build-times-results to build-metrics
davidwendt Dec 8, 2021
5f26a41
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Dec 9, 2021
4a8b7e7
add total compile-time to output
davidwendt Dec 9, 2021
58e6b2a
temp fix to get past cmake style check
davidwendt Dec 9, 2021
5a771a1
fix typo in build script
davidwendt Dec 9, 2021
2ec30e9
another typo in variable name in build.sh
davidwendt Dec 9, 2021
cbdaefe
check ccache exists before calling it
davidwendt Dec 9, 2021
5a519d2
add parallel-level value to build time message
davidwendt Dec 10, 2021
33e6716
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Dec 10, 2021
165ac24
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Dec 11, 2021
ed5c2b9
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Dec 13, 2021
95324e9
Merge branch 'branch-22.02' into build-format-ninja-log
davidwendt Dec 14, 2021
1d1b8a0
add choices [csv,xml,html] to argparse
davidwendt Dec 14, 2021
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
15 changes: 15 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ if buildAll || hasArg libcudf; then
echo "Building for *ALL* supported GPU architectures..."
fi

# get the current count before the compile starts
FILES_IN_CCACHE=$(ccache -s | grep "files in cache")
davidwendt marked this conversation as resolved.
Show resolved Hide resolved

cmake -S $REPODIR/cpp -B ${LIB_BUILD_DIR} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
${CUDF_CMAKE_CUDA_ARCHITECTURES} \
Expand All @@ -185,7 +188,19 @@ if buildAll || hasArg libcudf; then

cd ${LIB_BUILD_DIR}

compile_start=$(date +%s)
cmake --build . -j${PARALLEL_LEVEL} ${VERBOSE_FLAG}
compile_end=$(date +%s)
compile_total=$(( compile_end - compile_start ))

# Record build times
if [[ -f "${LIB_BUILD_DIR}/.ninja_log" ]]; then
echo "Formatting build times"
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 <p>CI build time = $compile_total"
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
fi

if [[ ${INSTALL_TARGET} != "" ]]; then
cmake --build . -j${PARALLEL_LEVEL} --target install ${VERBOSE_FLAG}
Expand Down
12 changes: 11 additions & 1 deletion ci/gpu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,26 @@ else
gpuci_logger "Check GPU usage"
nvidia-smi

gpuci_logger "GoogleTests"
set -x
cd $LIB_BUILD_DIR

gpuci_logger "GoogleTests"

for gt in gtests/* ; do
test_name=$(basename ${gt})
echo "Running GoogleTest $test_name"
${gt} --gtest_output=xml:"$WORKSPACE/test-results/"
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
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

################################################################################
# MEMCHECK - Run compute-sanitizer on GoogleTest (only in nightly builds)
################################################################################
Expand Down
3 changes: 2 additions & 1 deletion cpp/cmake/thirdparty/get_dlpack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function(find_and_configure_dlpack VERSION)
dlpack ${VERSION}
GIT_REPOSITORY https://github.com/dmlc/dlpack.git
GIT_TAG v${VERSION}
GIT_SHALLOW TRUE DOWNLOAD_ONLY TRUE
GIT_SHALLOW TRUE
DOWNLOAD_ONLY TRUE
OPTIONS "BUILD_MOCK OFF"
)

Expand Down
3 changes: 2 additions & 1 deletion cpp/cmake/thirdparty/get_jitify.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ function(find_and_configure_jitify)
jitify 2.0.0
GIT_REPOSITORY https://github.com/rapidsai/jitify.git
GIT_TAG cudf_0.19
GIT_SHALLOW TRUE DOWNLOAD_ONLY TRUE
GIT_SHALLOW TRUE
DOWNLOAD_ONLY TRUE
)
set(JITIFY_INCLUDE_DIR
"${jitify_SOURCE_DIR}"
Expand Down
5 changes: 3 additions & 2 deletions cpp/cmake/thirdparty/get_libcudacxx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ function(find_and_configure_libcudacxx)
include(${rapids-cmake-dir}/cpm/libcudacxx.cmake)

rapids_cpm_libcudacxx(
BUILD_EXPORT_SET cudf-exports INSTALL_EXPORT_SET cudf-exports PATCH_COMMAND patch
--reject-file=- -p1 -N < ${CUDF_SOURCE_DIR}/cmake/libcudacxx.patch || true
BUILD_EXPORT_SET cudf-exports
INSTALL_EXPORT_SET cudf-exports PATCH_COMMAND patch --reject-file=- -p1 -N <
${CUDF_SOURCE_DIR}/cmake/libcudacxx.patch || true
)

set(LIBCUDACXX_INCLUDE_DIR
Expand Down
117 changes: 117 additions & 0 deletions cpp/scripts/sort_ninja_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#
# Copyright (c) 2021, NVIDIA CORPORATION.
#
import argparse
import os
import sys
import xml.etree.ElementTree as ET
from xml.dom import minidom

parser = argparse.ArgumentParser()
parser.add_argument(
"log_file", type=str, default=".ninja_log", help=".ninja_log file"
)
parser.add_argument(
"--fmt", type=str, default="csv", help="output format (csv, xml, html)"
karthikeyann marked this conversation as resolved.
Show resolved Hide resolved
)
parser.add_argument(
"--msg",
type=str,
default=None,
help="optional message to include in html output",
)
args = parser.parse_args()

log_file = args.log_file
log_path = os.path.dirname(os.path.abspath(log_file))

output_fmt = args.fmt

# build a map of the log entries
entries = {}
with open(log_file, "r") as log:
for line in log:
entry = line.split()
if len(entry) > 4:
elapsed = int(entry[1]) - int(entry[0])
obj_file = entry[3]
file_size = (
os.path.getsize(os.path.join(log_path, obj_file))
if os.path.exists(obj_file)
else 0
)
entries[entry[3]] = (elapsed, file_size)

# check file could be loaded
if len(entries) == 0:
print("Could not parse", log_file)
exit()

# sort the keys by build time (descending order)
keys = list(entries.keys())
sl = sorted(keys, key=lambda k: entries[k][0], reverse=True)

if output_fmt == "xml":
# output results in XML format
root = ET.Element("testsuites")
testsuite = ET.Element(
"testsuite",
attrib={
"name": "build-time",
"tests": str(len(keys)),
"failures": str(0),
"errors": str(0),
},
)
root.append(testsuite)
for key in sl:
entry = entries[key]
elapsed = float(entry[0]) / 1000
item = ET.Element(
"testcase",
attrib={
"classname": "BuildTime",
"name": key,
"time": str(elapsed),
},
)
testsuite.append(item)

tree = ET.ElementTree(root)
xmlstr = minidom.parseString(ET.tostring(root)).toprettyxml(indent=" ")
print(xmlstr)

elif output_fmt == "html":
# output results in HTML format
print("<html><head><title>Sorted Ninja Build Times</title>")
print("<style>", "table, th, td { border:1px solid black; }", "</style>")
print("</head><body>")
if args.msg is not None:
print("<p>", args.msg, "</p>")
print("<table>")
print(
"<tr><th>File</th>",
"<th align='right'>Compile time (ms)</th>",
"<th align='right'>Size (bytes)</th><tr>",
sep="",
)
for key in sl:
result = entries[key]
print(
"<tr><td>",
key,
"</td><td align='right'>",
result[0],
"</td><td align='right'>",
result[1],
"</td></tr>",
sep="",
)
print("</table></body></html>")

else:
# output results in CSV format
print("time,size,file")
for key in sl:
result = entries[key]
print(result[0], result[1], key, sep=",")