You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ac...@apache.org on 2025/08/11 18:50:45 UTC

(kudu) 01/02: [tablet] remove last vestiges of AtomicInt from tablet

This is an automated email from the ASF dual-hosted git repository.

achennaka pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 3271ebbf42a181edc3d5bd54c05d76bbac5f2d84
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Fri Aug 8 18:16:16 2025 -0700

    [tablet] remove last vestiges of AtomicInt from tablet
    
    This patch switches 'mem_tracker_id_counter' and 'deleted_row_count_'
    in DeltaMemStore from Chromium-based Atomic to std::atomic.
    
    This changelist doesn't contain any functional modifications.
    
    Change-Id: I562f5419ba725823ac6333473706cc36a6676d1a
    Reviewed-on: http://gerrit.cloudera.org:8080/23274
    Tested-by: Alexey Serbin <al...@apache.org>
    Reviewed-by: Zoltan Martonka <zm...@cloudera.com>
    Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
---
 src/kudu/tablet/deltamemstore.cc | 9 ++++-----
 src/kudu/tablet/deltamemstore.h  | 6 +++---
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/kudu/tablet/deltamemstore.cc b/src/kudu/tablet/deltamemstore.cc
index 2aa7f8287..88073de04 100644
--- a/src/kudu/tablet/deltamemstore.cc
+++ b/src/kudu/tablet/deltamemstore.cc
@@ -103,7 +103,8 @@ Status DeltaMemStore::Update(Timestamp timestamp,
   if (PREDICT_FALSE(mutation.exists())) {
     // We already have a delta for this row at the same timestamp.
     // Try again with a disambiguating sequence number appended to the key.
-    int seq = disambiguator_sequence_number_.Increment();
+    const uint32_t seq = disambiguator_sequence_number_.fetch_add(
+        1, std::memory_order_release);
     PutMemcmpableVarint64(&buf, seq);
     key_slice = Slice(buf);
     mutation.Reset(key_slice);
@@ -119,7 +120,7 @@ Status DeltaMemStore::Update(Timestamp timestamp,
   RETURN_NOT_OK(anchorer_.AnchorIfMinimum(op_id.index()));
 
   if (update.is_delete()) {
-    deleted_row_count_.Increment();
+    deleted_row_count_.fetch_add(1, std::memory_order_relaxed);
   }
 
   std::lock_guard l(ts_lock_);
@@ -188,9 +189,7 @@ void DeltaMemStore::DebugPrint() const {
 }
 
 int64_t DeltaMemStore::deleted_row_count() const {
-  int64_t count = deleted_row_count_.Load();
-  DCHECK_GE(count, 0);
-  return count;
+  return deleted_row_count_.load(std::memory_order_relaxed);
 }
 
 ////////////////////////////////////////////////////////////
diff --git a/src/kudu/tablet/deltamemstore.h b/src/kudu/tablet/deltamemstore.h
index 5613524af..19f7f2535 100644
--- a/src/kudu/tablet/deltamemstore.h
+++ b/src/kudu/tablet/deltamemstore.h
@@ -16,6 +16,7 @@
 // under the License.
 #pragma once
 
+#include <atomic>
 #include <cstddef>
 #include <cstdint>
 #include <memory>
@@ -32,7 +33,6 @@
 #include "kudu/tablet/concurrent_btree.h"
 #include "kudu/tablet/delta_stats.h"
 #include "kudu/tablet/delta_store.h"
-#include "kudu/util/atomic.h"
 #include "kudu/util/locks.h"
 #include "kudu/util/make_shared.h"
 #include "kudu/util/memory/arena.h"
@@ -199,10 +199,10 @@ class DeltaMemStore : public DeltaStore,
   // in the underlying tree, so that the later operations will sort after
   // the earlier ones. This atomic integer serves to provide such a sequence
   // number, and is only used in the case that such a collision occurs.
-  AtomicInt<Atomic32> disambiguator_sequence_number_;
+  std::atomic<uint32_t> disambiguator_sequence_number_;
 
   // Number of deleted rows in this DMS.
-  AtomicInt<int64_t> deleted_row_count_;
+  std::atomic<int64_t> deleted_row_count_;
 
   DISALLOW_COPY_AND_ASSIGN(DeltaMemStore);
 };