Skip to content

Commit

Permalink
Fix the timers macro, configure it with a cmake option
Browse files Browse the repository at this point in the history
The build failed with the timers enabled as new variables have been
introduced in the normal code with names like `timer` that clash
once the timer macros are compiled in.
  • Loading branch information
Alex Seaton authored and poodlewars committed Oct 18, 2024
1 parent b20a677 commit 04bbd7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ option(
option(ARCTICDB_USING_ADDRESS_SANITIZER "Enable address sanitizer." OFF)
option(ARCTICDB_USING_THREAD_SANITIZER "Enable thread sanitizer." OFF)
option(ARCTICDB_USING_UB_SANITIZER "Enable undefined behavior sanitizer." OFF)
option(ARCTICDB_LOG_PERFORMANCE "Whether to log performance timings." OFF)

set(ARCTICDB_SANITIZER_FLAGS)
if(${ARCTICDB_USING_ADDRESS_SANITIZER})
Expand All @@ -42,6 +43,10 @@ if(${ARCTICDB_USING_UB_SANITIZER})
message(STATUS "Building ArcticDB with UB Sanitizer")
endif()

if(${ARCTICDB_LOG_PERFORMANCE})
add_compile_definitions(ARCTICDB_LOG_PERFORMANCE)
endif()

if(ARCTICDB_SANITIZER_FLAGS)
list(APPEND ARCTICDB_SANITIZER_FLAGS "-g;-fno-omit-frame-pointer;-fno-optimize-sibling-calls;")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Expand Down
8 changes: 4 additions & 4 deletions cpp/arcticdb/entity/performance_tracing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,22 @@ void set_remotery_thread_name(const char* task_name);

#elif defined(ARCTICDB_LOG_PERFORMANCE)
#define ARCTICDB_SAMPLE(name, flags) \
arcticdb::ScopedTimer timer{#name, [](auto msg) { \
arcticdb::ScopedTimer _timer{#name, [](auto msg) { \
std::cout << msg; \
}};

#define ARCTICDB_SUBSAMPLE(name, flags) \
arcticdb::ScopedTimer sub_timer_##name{#name, [](auto msg) { \
arcticdb::ScopedTimer _sub_timer_##name{#name, [](auto msg) { \
std::cout << msg; \
}};

#define ARCTICDB_SAMPLE_DEFAULT(name) \
arcticdb::ScopedTimer default_timer{#name, [](auto msg) { \
arcticdb::ScopedTimer _default_timer{#name, [](auto msg) { \
std::cout << msg; \
}};

#define ARCTICDB_SUBSAMPLE_DEFAULT(name) \
arcticdb::ScopedTimer sub_timer_##name{#name, [](auto msg) { \
arcticdb::ScopedTimer _sub_timer_##name{#name, [](auto msg) { \
std::cout << msg; \
}};

Expand Down

0 comments on commit 04bbd7f

Please sign in to comment.