mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
build: add -ftime-trace support for compilation profiling
Add a --time-trace flag to configure.py and a Scylla_TIME_TRACE CMake option that enable Clang's -ftime-trace on all C++ compilations. When enabled, each .o file produces a companion .json trace that can be analyzed with ClangBuildAnalyzer or loaded in chrome://tracing to identify slow headers and costly template instantiations. This is the first step toward data-driven build speed improvements. Refs #1 Usage: configure.py: ./configure.py --time-trace --mode dev CMake: cmake -DScylla_TIME_TRACE=ON -DCMAKE_BUILD_TYPE=Dev .. Closes scylladb/scylladb#29462
This commit is contained in:
committed by
Botond Dénes
parent
85d0011b3c
commit
b8a150e22c
@@ -137,6 +137,24 @@ endfunction()
|
||||
|
||||
option(Scylla_WITH_DEBUG_INFO "Enable debug info" OFF)
|
||||
|
||||
# Time trace profiling: adds -ftime-trace to all C++ compilations (Clang only).
|
||||
# Each .o produces a companion .json file in the build directory that can be
|
||||
# analyzed with ClangBuildAnalyzer or loaded in chrome://tracing.
|
||||
#
|
||||
# Usage:
|
||||
# cmake -DScylla_TIME_TRACE=ON ...
|
||||
# ninja
|
||||
# # Analyze results (requires ClangBuildAnalyzer):
|
||||
# ClangBuildAnalyzer --all <build-dir> capture.bin
|
||||
# ClangBuildAnalyzer --analyze capture.bin
|
||||
option(Scylla_TIME_TRACE "Enable Clang -ftime-trace for build profiling" OFF)
|
||||
if(Scylla_TIME_TRACE)
|
||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
message(FATAL_ERROR "Scylla_TIME_TRACE requires Clang (found ${CMAKE_CXX_COMPILER_ID})")
|
||||
endif()
|
||||
add_compile_options(-ftime-trace)
|
||||
endif()
|
||||
|
||||
macro(update_build_flags config)
|
||||
cmake_parse_arguments (
|
||||
parsed_args
|
||||
|
||||
@@ -858,6 +858,10 @@ arg_parser.add_argument('--coverage', action = 'store_true', help = 'Compile scy
|
||||
arg_parser.add_argument('--build-dir', action='store', default='build',
|
||||
help='Build directory path')
|
||||
arg_parser.add_argument('--disable-precompiled-header', action='store_true', default=False, help='Disable precompiled header for scylla binary')
|
||||
arg_parser.add_argument('--time-trace', action='store_true', default=False,
|
||||
help='Enable Clang -ftime-trace for build profiling. '
|
||||
'Each .o produces a .json file analyzable with '
|
||||
'ClangBuildAnalyzer or chrome://tracing')
|
||||
arg_parser.add_argument('-h', '--help', action='store_true', help='show this help message and exit')
|
||||
args = arg_parser.parse_args()
|
||||
if args.help:
|
||||
@@ -1971,6 +1975,9 @@ user_cflags += ' -fextend-variable-liveness=none'
|
||||
if args.target != '':
|
||||
user_cflags += ' -march=' + args.target
|
||||
|
||||
if args.time_trace:
|
||||
user_cflags += ' -ftime-trace'
|
||||
|
||||
for mode in modes:
|
||||
# Those flags are passed not only to Scylla objects, but also to libraries
|
||||
# that we compile ourselves.
|
||||
|
||||
Reference in New Issue
Block a user