diff --git a/ConflictSet.cpp b/ConflictSet.cpp index f8aac2f..4131978 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -29,6 +29,7 @@ limitations under the License. #include #include #include +#include #include #include @@ -3067,9 +3068,15 @@ Node *firstGeqPhysical(Node *n, const std::span key) { } } +#define MEASURE_CHECK_CPU_TIME 0 + struct __attribute__((visibility("hidden"))) ConflictSet::Impl { void check(const ReadRange *reads, Result *result, int count) { +#if MEASURE_CHECK_CPU_TIME + timespec ts_begin; + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts_begin); +#endif int commits_accum = 0; int conflicts_accum = 0; int too_olds_accum = 0; @@ -3115,6 +3122,13 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { conflicts_total.add(conflicts_accum); too_olds_total.add(too_olds_accum); check_bytes_total.add(check_byte_accum); +#if MEASURE_CHECK_CPU_TIME + timespec ts_end; + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts_end); + check_cpu_seconds_total.add( + std::max(0, (ts_end.tv_nsec * 1e-9 + ts_end.tv_sec) - + (ts_begin.tv_nsec * 1e-9 + ts_begin.tv_sec))); +#endif } void addWrites(const WriteRange *writes, int count, int64_t writeVersion) { @@ -3329,6 +3343,10 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { COUNTER(too_olds_total, "Total number of checks where the result is \"too old\""); COUNTER(check_bytes_total, "Total number of key bytes checked"); +#if MEASURE_CHECK_CPU_TIME + COUNTER(check_cpu_seconds_total, + "Total cpu seconds spent in a call to check"); +#endif // ==================== END METRICS DEFINITIONS ==================== #undef GAUGE #undef COUNTER