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

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


The following commit(s) were added to refs/heads/master by this push:
     new e7182586121 [opt](point query) reduce short circuit lookup cache usage 
(#67228)
e7182586121 is described below

commit e7182586121963db8524bebaa70e72d9acf2c34d
Author: HonestManXin <[email protected]>
AuthorDate: Tue Oct 13 10:38:48 2026 +0800

    [opt](point query) reduce short circuit lookup cache usage (#67228)
    
    LookupConnectionCache preallocates 32 reusable Blocks for each cached
    point-query context. For wide tables, these Blocks dominate the cache
    memory usage, and the overhead grows significantly with the number of
    client connections.
    In the current implementation, a Reusable instance is not shared across
    client connections, and requests within the same connection are executed
    serially. Therefore, the concurrency of each Reusable instance does not
    exceed one, making it unnecessary to preallocate 32 Blocks.
    This change makes the Block pool size configurable and reduces the
    default size from 32 to 1. If concurrent access is introduced in the
    future, additional Blocks can still be allocated on demand, while the
    pool retains only the configured number of idle Blocks.
    In a real production online point-query workload querying a wide table
    with about 80 columns through approximately 8,000 client connections,
    the LookupConnectionCache memory usage on a single BE was reduced from
    about 10 GB to 1.8 GB.
---
 be/src/common/config.cpp                 | 16 ++++++++++++++++
 be/src/common/config.h                   |  4 ++++
 be/src/service/point_query_executor.cpp  | 16 +++++-----------
 be/test/common/config_validator_test.cpp | 19 +++++++++++++++++++
 4 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp
index dec047775db..e8e31d06e5d 100644
--- a/be/src/common/config.cpp
+++ b/be/src/common/config.cpp
@@ -1570,6 +1570,19 @@ DEFINE_mInt64(auto_inc_low_water_level_mark_size_ratio, 
"3");
 DEFINE_mInt64(auto_inc_fetch_thread_num, "3");
 // default max to 2048 connections
 DEFINE_mInt64(lookup_connection_cache_capacity, "2048");
+// Number of reusable result blocks retained by each point lookup cache entry, 
in [1, 32].
+DEFINE_mInt32(lookup_connection_cache_block_pool_size, "1");
+DEFINE_Validator(lookup_connection_cache_block_pool_size,
+                 [](int32_t value) -> bool { return value >= 1 && value <= 32; 
});
+static std::atomic<size_t> atomic_lookup_connection_cache_block_pool_size {1};
+DEFINE_ON_UPDATE(lookup_connection_cache_block_pool_size, [](int32_t, int32_t 
value) {
+    
atomic_lookup_connection_cache_block_pool_size.store(static_cast<size_t>(value),
+                                                         
std::memory_order_relaxed);
+});
+
+size_t get_lookup_connection_cache_block_pool_size() {
+    return 
atomic_lookup_connection_cache_block_pool_size.load(std::memory_order_relaxed);
+}
 
 // level of compression when using LZ4_HC, whose defalut value is 
LZ4HC_CLEVEL_DEFAULT
 DEFINE_mInt64(LZ4_HC_compression_level, "9");
@@ -2408,6 +2421,9 @@ bool init(const char* conf_file, bool fill_conf_map, bool 
must_exist, bool set_t
     }
     published_inverted_index_candidate_pushdown_ratio.store(
             inverted_index_candidate_pushdown_ratio);
+    atomic_lookup_connection_cache_block_pool_size.store(
+            static_cast<size_t>(lookup_connection_cache_block_pool_size),
+            std::memory_order_relaxed);
 
     // Emit a warning for every key present in the conf file that does not 
correspond to a
     // registered BE config field. Such keys (typos or configs removed in a 
newer version)
diff --git a/be/src/common/config.h b/be/src/common/config.h
index 6b1b3db2569..bd485388ae0 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -17,6 +17,7 @@
 
 #pragma once
 
+#include <cstddef>
 #include <cstdint>
 #include <functional>
 #include <map>
@@ -1618,6 +1619,9 @@ DECLARE_mInt64(auto_inc_low_water_level_mark_size_ratio);
 DECLARE_mInt64(auto_inc_fetch_thread_num);
 // Max connection cache num for point lookup queries
 DECLARE_mInt64(lookup_connection_cache_capacity);
+// Number of reusable result blocks retained by each point lookup cache entry, 
in [1, 32].
+DECLARE_mInt32(lookup_connection_cache_block_pool_size);
+size_t get_lookup_connection_cache_block_pool_size();
 
 // level of compression when using LZ4_HC, whose defalut value is 
LZ4HC_CLEVEL_DEFAULT
 DECLARE_mInt64(LZ4_HC_compression_level);
diff --git a/be/src/service/point_query_executor.cpp 
b/be/src/service/point_query_executor.cpp
index 88c035d06ca..533ea625cae 100644
--- a/be/src/service/point_query_executor.cpp
+++ b/be/src/service/point_query_executor.cpp
@@ -112,8 +112,6 @@ static void get_missing_and_include_cids(const 
TabletSchema& schema,
     }
 }
 
-constexpr static int s_preallocted_blocks_num = 32;
-
 static void extract_slot_ref(const VExprSPtr& expr, TupleDescriptor* 
tuple_desc,
                              std::vector<SlotDescriptor*>& slots) {
     const auto& children = expr->children();
@@ -212,8 +210,9 @@ void Reusable::return_block(std::unique_ptr<Block>& block) {
     }
     block->clear_column_data();
     _block_pool.push_back(std::move(block));
-    if (_block_pool.size() > s_preallocted_blocks_num) {
-        _block_pool.resize(s_preallocted_blocks_num);
+    const auto block_pool_size = 
config::get_lookup_connection_cache_block_pool_size();
+    if (_block_pool.size() > block_pool_size) {
+        _block_pool.resize(block_pool_size);
     }
 }
 
@@ -350,15 +349,10 @@ Status PointQueryExecutor::init(const 
PTabletKeyLookupRequest* request,
                     reinterpret_cast<const 
uint8_t*>(request->query_options().data()), &len, false,
                     &t_query_options));
         }
+        RETURN_IF_ERROR(reusable_ptr->init(t_desc_tbl, t_output_exprs.exprs, 
t_query_options,
+                                           *_tablet->tablet_schema(), 1));
         if (uuid != 0) {
-            // could be reused by requests after, pre allocte more blocks
-            RETURN_IF_ERROR(reusable_ptr->init(t_desc_tbl, 
t_output_exprs.exprs, t_query_options,
-                                               *_tablet->tablet_schema(),
-                                               s_preallocted_blocks_num));
             LookupConnectionCache::instance()->add(uuid, reusable_ptr);
-        } else {
-            RETURN_IF_ERROR(reusable_ptr->init(t_desc_tbl, 
t_output_exprs.exprs, t_query_options,
-                                               *_tablet->tablet_schema(), 1));
         }
     }
     _init_remote_scan_cache_write_limiter();
diff --git a/be/test/common/config_validator_test.cpp 
b/be/test/common/config_validator_test.cpp
index f12dedd5dbd..122709cf8a9 100644
--- a/be/test/common/config_validator_test.cpp
+++ b/be/test/common/config_validator_test.cpp
@@ -83,4 +83,23 @@ TEST_F(ConfigValidatorTest, Validator) {
     EXPECT_EQ(cfg_validator_2, 8);
 }
 
+TEST(ConfigValidatorTest, LookupConnectionCacheBlockPoolSize) {
+    const auto old_value = 
config::get_lookup_connection_cache_block_pool_size();
+
+    EXPECT_TRUE(config::set_config("lookup_connection_cache_block_pool_size", 
"1").ok());
+    EXPECT_EQ(config::get_lookup_connection_cache_block_pool_size(), 1);
+    EXPECT_FALSE(config::set_config("lookup_connection_cache_block_pool_size", 
"0").ok());
+    EXPECT_FALSE(config::set_config("lookup_connection_cache_block_pool_size", 
"-1").ok());
+    EXPECT_EQ(config::get_lookup_connection_cache_block_pool_size(), 1);
+
+    EXPECT_TRUE(config::set_config("lookup_connection_cache_block_pool_size", 
"32").ok());
+    EXPECT_EQ(config::get_lookup_connection_cache_block_pool_size(), 32);
+    EXPECT_FALSE(config::set_config("lookup_connection_cache_block_pool_size", 
"33").ok());
+    EXPECT_EQ(config::get_lookup_connection_cache_block_pool_size(), 32);
+
+    EXPECT_TRUE(
+            config::set_config("lookup_connection_cache_block_pool_size", 
std::to_string(old_value))
+                    .ok());
+}
+
 } // namespace doris


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to