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


The following commit(s) were added to refs/heads/master by this push:
     new 1b7d2a173 [tablet] avoid multiple TabletMetadata::extra_config() calls
1b7d2a173 is described below

commit 1b7d2a1731c15c4644e94967b769bc6154760dba
Author: Alexey Serbin <ale...@apache.org>
AuthorDate: Mon Mar 20 18:23:58 2023 -0700

    [tablet] avoid multiple TabletMetadata::extra_config() calls
    
    This patch optimizes the code in tablet.cc a bit to avoid acquiring
    a lock multiple times when examining extra table configuration
    in Tablet::{GetTabletAncientHistoryMark,disable_compaction}() methods.
    
    Change-Id: I346d1c8813dab8924e84eaf4ef8bd7fd6623619e
    Reviewed-on: http://gerrit.cloudera.org:8080/19637
    Reviewed-by: Mahesh Reddy <mre...@cloudera.com>
    Reviewed-by: Yingchun Lai <laiyingc...@apache.org>
    Tested-by: Yingchun Lai <laiyingc...@apache.org>
---
 src/kudu/tablet/tablet.cc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index ef6b77cee..008d11291 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -1467,9 +1467,10 @@ Status Tablet::DoMajorDeltaCompaction(const 
vector<ColumnId>& col_ids,
 
 bool Tablet::GetTabletAncientHistoryMark(Timestamp* ancient_history_mark) 
const {
   int32_t tablet_history_max_age_sec = FLAGS_tablet_history_max_age_sec;
-  if (metadata_->extra_config() && 
metadata_->extra_config()->has_history_max_age_sec()) {
+  const auto& extra_config = metadata_->extra_config();
+  if (extra_config && extra_config->has_history_max_age_sec()) {
     // Override the global configuration with the configuration of the table
-    tablet_history_max_age_sec = 
metadata_->extra_config()->history_max_age_sec();
+    tablet_history_max_age_sec = extra_config->history_max_age_sec();
   }
   // We currently only support history GC through a fully-instantiated tablet
   // when using the HybridClock, since we can calculate the age of a mutation.
@@ -1835,8 +1836,9 @@ Status Tablet::PickRowSetsToCompact(RowSetsInCompaction 
*picked,
 }
 
 bool Tablet::disable_compaction() const {
-  if (metadata_->extra_config() && 
metadata_->extra_config()->has_disable_compaction()) {
-    return metadata_->extra_config()->disable_compaction();
+  const auto& extra_config = metadata_->extra_config();
+  if (extra_config && extra_config->has_disable_compaction()) {
+    return extra_config->disable_compaction();
   }
   return false;
 }

Reply via email to