diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 20193e8..92425e3 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -729,6 +729,8 @@ struct WriteContext { double entries_inserted_accum = 0; double nodes_allocated_accum = 0; double nodes_released_accum = 0; + double point_writes_accum = 0; + double range_writes_accum = 0; template T *allocate(int c) { ++nodes_allocated_accum; if constexpr (std::is_same_v) { @@ -2949,6 +2951,7 @@ void destroyTree(Node *root) { void addPointWrite(Node *&root, std::span key, InternalVersionT writeVersion, WriteContext *tls, ConflictSet::Impl *impl) { + ++tls->point_writes_accum; auto *n = insert(&root, key, writeVersion, tls, impl); if (!n->entryPresent) { ++tls->entries_inserted_accum; @@ -2978,6 +2981,7 @@ void addWriteRange(Node *&root, std::span begin, end.back() == 0) { return addPointWrite(root, begin, writeVersion, tls, impl); } + ++tls->range_writes_accum; const bool beginIsPrefix = lcp == int(begin.size()); auto remaining = begin.subspan(0, lcp); @@ -3200,8 +3204,6 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { } double write_byte_accum = 0; - int point_writes_accum = 0; - int range_writes_accum = 0; for (int i = 0; i < count; ++i) { const auto &w = writes[i]; write_byte_accum += w.begin.len + w.end.len; @@ -3209,19 +3211,17 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { auto end = std::span(w.end.p, w.end.len); if (w.end.len > 0) { keyUpdates += 3; - ++range_writes_accum; addWriteRange(root, begin, end, InternalVersionT(writeVersion), &tls, this); } else { keyUpdates += 2; - ++point_writes_accum; addPointWrite(root, begin, InternalVersionT(writeVersion), &tls, this); } } memory_bytes.set(totalBytes); - point_writes_total.add(point_writes_accum); - range_writes_total.add(range_writes_accum); + point_writes_total.add(std::exchange(tls.point_writes_accum, 0)); + range_writes_total.add(std::exchange(tls.range_writes_accum, 0)); nodes_allocated_total.add(std::exchange(tls.nodes_allocated_accum, 0)); nodes_released_total.add(std::exchange(tls.nodes_released_accum, 0)); entries_inserted_total.add(std::exchange(tls.entries_inserted_accum, 0));