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

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

commit 242b465f8cc16aaf0ca80d76f602d2a551d75e76
Author: Alexey Serbin <[email protected]>
AuthorDate: Fri Jan 2 21:46:38 2026 -0800

    [codegen] relax memory ordering for metric updates
    
    Since 'code_cache_hits' and 'code_cache_queries' are used as metric
    gauges only and aren't consumed in any way that would require strong
    consistency guarantees, it makes sense to switch from the
    'memory_order_seq_cst' to the 'memory_order_relaxed' when updating
    the underlying '{hit,query}_counter_' atomic counters.
    
    Change-Id: Id874786ff5c6f83c1b84b747064808e2d939d3fb
    Reviewed-on: http://gerrit.cloudera.org:8080/23820
    Reviewed-by: Zoltan Martonka <[email protected]>
    Tested-by: Alexey Serbin <[email protected]>
    Reviewed-by: Abhishek Chennaka <[email protected]>
---
 src/kudu/codegen/compilation_manager.cc | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/kudu/codegen/compilation_manager.cc 
b/src/kudu/codegen/compilation_manager.cc
index 615273644..c8e228349 100644
--- a/src/kudu/codegen/compilation_manager.cc
+++ b/src/kudu/codegen/compilation_manager.cc
@@ -46,6 +46,7 @@
 #include "kudu/util/threadpool.h"
 
 using std::make_shared;
+using std::memory_order;
 using std::shared_ptr;
 using std::unique_ptr;
 
@@ -141,9 +142,9 @@ class CompilationTask final {
 } // anonymous namespace
 
 CompilationManager::CompilationManager()
-  : cache_(FLAGS_codegen_cache_capacity),
-    hit_counter_(0),
-    query_counter_(0) {
+    : cache_(FLAGS_codegen_cache_capacity),
+      hit_counter_(0),
+      query_counter_(0) {
   CHECK_OK(ThreadPoolBuilder("compiler_manager_pool")
            .set_min_threads(0)
            
.set_max_threads(FLAGS_codegen_compiler_manager_pool_max_threads_num)
@@ -179,12 +180,12 @@ Status CompilationManager::StartInstrumentation(const 
scoped_refptr<MetricEntity
   metric_entity->NeverRetire(METRIC_code_cache_hits.InstantiateFunctionGauge(
       metric_entity,
       [this]() {
-        return 
this->hit_counter_.load(std::memory_order::memory_order_relaxed);
+        return this->hit_counter_.load(memory_order::memory_order_relaxed);
       }));
   
metric_entity->NeverRetire(METRIC_code_cache_queries.InstantiateFunctionGauge(
       metric_entity,
       [this]() {
-        return 
this->query_counter_.load(std::memory_order::memory_order_relaxed);
+        return this->query_counter_.load(memory_order::memory_order_relaxed);
       }));
   return Status::OK();
 }
@@ -199,7 +200,7 @@ bool CompilationManager::RequestRowProjector(const Schema* 
base_schema,
                  << s.ToString();
     return false;
   }
-  ++query_counter_;
+  query_counter_.fetch_add(1, memory_order::memory_order_relaxed);
 
   scoped_refptr<RowProjectorFunctions> cached(
       down_cast<RowProjectorFunctions*>(cache_.Lookup(key).get()));
@@ -212,10 +213,10 @@ bool CompilationManager::RequestRowProjector(const 
Schema* base_schema,
                     "RowProjector compilation request submit failed", 10);
     return false;
   }
+  hit_counter_.fetch_add(1, memory_order::memory_order_relaxed);
 
-  ++hit_counter_;
+  out->reset(new RowProjector(base_schema, projection, std::move(cached)));
 
-  out->reset(new RowProjector(base_schema, projection, cached));
   return true;
 }
 

Reply via email to