From f6edde0e502e33358de2f5d7f6ef6a92c44dfdac Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 12 Jul 2024 14:49:46 -0700 Subject: [PATCH] Fix data race --- ConflictSet.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 6ce3d8a..c11ee2c 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -3060,9 +3060,18 @@ Node *firstGeqPhysical(Node *n, const std::span key) { } } +thread_local double accume_point_read = 0; +thread_local double accume_prefix_read = 0; +thread_local double accume_range_read = 0; +thread_local double accume_max_between = 0; + struct __attribute__((visibility("hidden"))) ConflictSet::Impl { void check(const ReadRange *reads, Result *result, int count) { + assert(accume_point_read == 0); + assert(accume_prefix_read == 0); + assert(accume_range_read == 0); + assert(accume_max_between == 0); for (int i = 0; i < count; ++i) { const auto &r = reads[i]; auto begin = std::span(r.begin.p, r.begin.len); @@ -3303,13 +3312,9 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { COUNTER(node256_released_total, "Total number of nodes of type \"Node256\" that have been released"); GAUGE(memory_bytes, "Total number of bytes in use."); - double accume_point_read = 0; COUNTER(read_point_total, "Total number of point reads checked."); - double accume_prefix_read = 0; COUNTER(read_prefix_total, "Total number of prefix reads checked."); - double accume_range_read = 0; COUNTER(read_range_total, "Total number of range reads checked."); - double accume_max_between = 0; COUNTER(read_range_node_total, "Total number of range checks of individual nodes while " "checking a range read.");