From d07581d82d2193096dd781ea3dd189c926baa163 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 6 May 2021 09:36:10 +0300 Subject: [PATCH] Count found keys for CacheDictionary --- src/Dictionaries/CacheDictionary.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Dictionaries/CacheDictionary.cpp b/src/Dictionaries/CacheDictionary.cpp index eadee988533..9bb8b34e74e 100644 --- a/src/Dictionaries/CacheDictionary.cpp +++ b/src/Dictionaries/CacheDictionary.cpp @@ -176,8 +176,9 @@ Columns CacheDictionary::getColumns( ProfileEvents::increment(ProfileEvents::DictCacheKeysExpired, expired_keys_size); ProfileEvents::increment(ProfileEvents::DictCacheKeysNotFound, not_found_keys_size); - query_count.fetch_add(keys.size()); - hit_count.fetch_add(found_keys_size); + query_count.fetch_add(keys.size(), std::memory_order_relaxed); + hit_count.fetch_add(found_keys_size, std::memory_order_relaxed); + found_count.fetch_add(found_keys_size, std::memory_order_relaxed); MutableColumns & fetched_columns_from_storage = result_of_fetch_from_storage.fetched_columns; const PaddedPODArray & key_index_to_state_from_storage = result_of_fetch_from_storage.key_index_to_state; @@ -296,8 +297,9 @@ ColumnUInt8::Ptr CacheDictionary::hasKeys(const Columns & k ProfileEvents::increment(ProfileEvents::DictCacheKeysExpired, expired_keys_size); ProfileEvents::increment(ProfileEvents::DictCacheKeysNotFound, not_found_keys_size); - query_count.fetch_add(keys.size()); - hit_count.fetch_add(found_keys_size); + query_count.fetch_add(keys.size(), std::memory_order_relaxed); + hit_count.fetch_add(found_keys_size, std::memory_order_relaxed); + found_count.fetch_add(found_keys_size, std::memory_order_relaxed); size_t keys_to_update_size = expired_keys_size + not_found_keys_size; auto update_unit = std::make_shared>(key_columns, result_of_fetch_from_storage.key_index_to_state, request, keys_to_update_size); @@ -368,6 +370,7 @@ ColumnPtr CacheDictionary::getHierarchy( size_t keys_found; auto result = getKeysHierarchyDefaultImplementation(this, key_column, key_type, keys_found); query_count.fetch_add(key_column->size(), std::memory_order_relaxed); + found_count.fetch_add(keys_found, std::memory_order_relaxed); return result; } else @@ -385,6 +388,7 @@ ColumnUInt8::Ptr CacheDictionary::isInHierarchy( size_t keys_found; auto result = getKeysIsInHierarchyDefaultImplementation(this, key_column, in_key_column, key_type, keys_found); query_count.fetch_add(key_column->size(), std::memory_order_relaxed); + found_count.fetch_add(keys_found, std::memory_order_relaxed); return result; } else @@ -670,6 +674,8 @@ void CacheDictionary::update(CacheDictionaryUpdateUnitPtr