From a8517e4167f5212b9cde02e772a3872350a1c134 Mon Sep 17 00:00:00 2001 From: saltonz Date: Fri, 21 Jun 2024 12:52:58 +0000 Subject: [PATCH] [CP] force cache hastable for cs encoder to avoid frequently page fault --- .../blocksstable/cs_encoding/ob_micro_block_cs_encoder.cpp | 4 ++-- src/storage/blocksstable/encoding/ob_encoding_hash_util.cpp | 4 ++-- src/storage/blocksstable/encoding/ob_encoding_hash_util.h | 2 +- src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/storage/blocksstable/cs_encoding/ob_micro_block_cs_encoder.cpp b/src/storage/blocksstable/cs_encoding/ob_micro_block_cs_encoder.cpp index 1694c63ae..57d28d957 100644 --- a/src/storage/blocksstable/cs_encoding/ob_micro_block_cs_encoder.cpp +++ b/src/storage/blocksstable/cs_encoding/ob_micro_block_cs_encoder.cpp @@ -976,7 +976,7 @@ int ObMicroBlockCSEncoder::prescan_(const int64_t column_index) if (OB_FAIL(ret)) { // avoid overwirte ret int temp_ret = OB_SUCCESS; - if (OB_SUCCESS != (temp_ret = hashtable_factory_.recycle(ht))) { + if (OB_SUCCESS != (temp_ret = hashtable_factory_.recycle(true, ht))) { LOG_WARN("recycle hashtable failed", K(temp_ret)); } } @@ -1271,7 +1271,7 @@ void ObMicroBlockCSEncoder::free_encoders_() FOREACH(ht, hashtables_) { // should continue even fail - if (OB_FAIL(hashtable_factory_.recycle(*ht))) { + if (OB_FAIL(hashtable_factory_.recycle(true, *ht))) { LOG_WARN("recycle hashtable failed", K(ret)); } } diff --git a/src/storage/blocksstable/encoding/ob_encoding_hash_util.cpp b/src/storage/blocksstable/encoding/ob_encoding_hash_util.cpp index 3b5a6ec09..68a324d38 100644 --- a/src/storage/blocksstable/encoding/ob_encoding_hash_util.cpp +++ b/src/storage/blocksstable/encoding/ob_encoding_hash_util.cpp @@ -283,7 +283,7 @@ int ObEncodingHashTableFactory::create(const int64_t bucket_num, const int64_t n return ret; } -int ObEncodingHashTableFactory::recycle(ObEncodingHashTable *hashtable) +int ObEncodingHashTableFactory::recycle(const bool force_cache, ObEncodingHashTable *hashtable) { int ret = OB_SUCCESS; if (NULL == hashtable) { @@ -292,7 +292,7 @@ int ObEncodingHashTableFactory::recycle(ObEncodingHashTable *hashtable) } else if (!hashtable->created()) { ret = OB_INVALID_ARGUMENT; LOG_WARN("hashtable not created", K(ret)); - } else if (hashtable->get_node_cnt() >= MAX_CACHED_HASHTABLE_SIZE) { + } else if (!force_cache && hashtable->get_node_cnt() >= MAX_CACHED_HASHTABLE_SIZE) { allocator_.free(hashtable); } else { if (OB_FAIL(hashtables_.push_back(hashtable))) { diff --git a/src/storage/blocksstable/encoding/ob_encoding_hash_util.h b/src/storage/blocksstable/encoding/ob_encoding_hash_util.h index 6222787b4..c4527ab02 100644 --- a/src/storage/blocksstable/encoding/ob_encoding_hash_util.h +++ b/src/storage/blocksstable/encoding/ob_encoding_hash_util.h @@ -301,7 +301,7 @@ public: int create(const int64_t bucket_num, const int64_t node_num, ObEncodingHashTable *&hashtable); - int recycle(ObEncodingHashTable *hashtable); + int recycle(const bool force_cache, ObEncodingHashTable *hashtable); private: void clear(); diff --git a/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp b/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp index 16c75af89..bd7d18625 100644 --- a/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp +++ b/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp @@ -1246,7 +1246,7 @@ int ObMicroBlockEncoder::prescan(const int64_t column_index) if (OB_FAIL(ret)) { // avoid overwirte ret int temp_ret = OB_SUCCESS; - if (OB_SUCCESS != (temp_ret = hashtable_factory_.recycle(ht))) { + if (OB_SUCCESS != (temp_ret = hashtable_factory_.recycle(false, ht))) { LOG_WARN("recycle hashtable failed", K(temp_ret)); } if (OB_SUCCESS != (temp_ret = multi_prefix_tree_factory_.recycle(prefix_tree))) { @@ -1829,7 +1829,7 @@ void ObMicroBlockEncoder::free_encoders() } FOREACH(ht, hashtables_) { // should continue even fail - if (OB_FAIL(hashtable_factory_.recycle(*ht))) { + if (OB_FAIL(hashtable_factory_.recycle(false, *ht))) { // overwrite ret LOG_WARN("recycle hashtable failed", K(ret)); }