Skip to content

Commit

Permalink
#2380: metrics: Add build configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Dec 13, 2024
1 parent e485ac7 commit 9bfd088
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions ci/build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ cmake -G "${CMAKE_GENERATOR:-Ninja}" \
-Dvt_build_extended_tests="${VT_EXTENDED_TESTS_ENABLED:-1}" \
-Dvt_zoltan_enabled="${VT_ZOLTAN_ENABLED:-0}" \
-Dvt_tv_enabled="${VT_TV_ENABLED:-0}" \
-Dvt_perf_enabled="${VT_PERF_ENABLED:-0}" \
-Dvt_production_build_enabled="${VT_PRODUCTION_BUILD_ENABLED:-0}" \
-Dvt_unity_build_enabled="${VT_UNITY_BUILD_ENABLED:-0}" \
-Dvt_diagnostics_enabled="${VT_DIAGNOSTICS_ENABLED:-1}" \
Expand Down
3 changes: 3 additions & 0 deletions cmake/configure_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ define_option(vt_rdma_tests_enabled "RDMA tests" "Build VT with RDMA tests enabl
ON vt_feature_cmake_rdma_tests
)

define_option(vt_perf_enabled "perf task measurement"
"Build VT with Linux perf to measure low level metrics of interest" OFF vt_feature_cmake_perf
)

#####################################################
#################### DIAGNOSTICS ####################
Expand Down
3 changes: 3 additions & 0 deletions cmake/load_packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ include(cmake/load_libunwind.cmake)
# Optionally link with Zoltan
include(cmake/load_zoltan_package.cmake)

# If enabled, test if perf is available and works
include(cmake/load_perf.cmake)

# Tests
include(cmake/test_vt.cmake)
45 changes: 45 additions & 0 deletions cmake/load_perf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
set(vt_perf_found "0")

if (vt_perf_enabled)
# check if linux
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# check if there's the perf header we need
include(CheckIncludeFiles)
CHECK_INCLUDE_FILES("linux/perf_event.h" HAVE_PERF_EVENT_H)
if (HAVE_PERF_EVENT_H)
# check if the kernel is recent enough
string(REPLACE "." ";" VERSION_LIST ${CMAKE_SYSTEM_VERSION})
list(GET VERSION_LIST 0 KERNEL_MAJOR_VERSION)
if (KERNEL_MAJOR_VERSION GREATER_EQUAL 4)
# check if a simple perf stat runs without issues
execute_process(
COMMAND perf stat pwd
RESULT_VARIABLE PERF_STAT_RESULT
OUTPUT_QUIET
ERROR_QUIET
)
if (PERF_STAT_RESULT EQUAL 0)
message(STATUS "Perf measurements enabled.")
set(vt_perf_enabled "1")
set(vt_perf_found "1")
else ()
message(WARNING "Perf disabled: \"perf stat\" results in non-zero error code.")
set(vt_perf_enabled "0")
set(vt_perf_found "0")
endif ()
else ()
message(WARNING "Perf disabled: kernel major version is less than 4.")
set(vt_perf_enabled "0")
set(vt_perf_found "0")
endif ()
else ()
message(WARNING "Perf disabled: could not find \"perf_event.h\".")
set(vt_perf_enabled "0")
set(vt_perf_found "0")
endif ()
else ()
message(WARNING "Perf disabled: system name is not Linux.")
set(vt_perf_enabled "0")
set(vt_perf_found "0")
endif ()
endif ()
1 change: 1 addition & 0 deletions cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#define vt_feature_cmake_external_fmt @vt_feature_cmake_external_fmt@
#define vt_feature_cmake_libunwind @vt_feature_cmake_libunwind@
#define vt_feature_cmake_tv @vt_feature_cmake_tv@
#define vt_feature_cmake_perf @vt_feature_cmake_perf@

#define vt_detected_max_num_nodes @cmake_detected_max_num_nodes@

Expand Down
1 change: 1 addition & 0 deletions src/vt/configs/features/features_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#define vt_feature_fmt_external 0 || vt_feature_cmake_external_fmt
#define vt_feature_libunwind 0 || vt_feature_cmake_libunwind
#define vt_feature_tv 0 || vt_feature_cmake_tv
#define vt_feature_perf 0 || vt_feature_cmake_perf

#define vt_check_enabled(test_option) (vt_feature_ ## test_option != 0)

Expand Down
1 change: 1 addition & 0 deletions src/vt/configs/features/features_featureswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
"debug prints disabled)"
#define vt_feature_str_trace_enabled "Tracing Projections"
#define vt_feature_str_zoltan "Zoltan for load balancing"
#define vt_feature_str_perf "perf for event measurement"

#endif /*INCLUDED_VT_CONFIGS_FEATURES_FEATURES_FEATURESWITCH_H*/

0 comments on commit 9bfd088

Please sign in to comment.