OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OverlapsTuningParamRecycler.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 std::optional<AutoTunerMetaInfo> OverlapsTuningParamRecycler::getItemFromCache(
20  QueryPlanHash key,
21  CacheItemType item_type,
22  DeviceIdentifier device_identifier,
23  std::optional<EMPTY_META_INFO> meta_info) const {
26  return std::nullopt;
27  }
29  std::lock_guard<std::mutex> lock(getCacheLock());
30  auto layout_cache = getCachedItemContainer(item_type, device_identifier);
31  auto param_cache = getCachedItem(key, *layout_cache);
32  if (param_cache) {
33  VLOG(1) << "[" << DataRecyclerUtil::toStringCacheItemType(item_type) << ", "
35  << "] Recycle auto tuner parameters for the overlaps hash join qual";
36  return param_cache->cached_item;
37  }
38  return std::nullopt;
39 }
40 
42  QueryPlanHash key,
43  std::optional<AutoTunerMetaInfo> item,
44  CacheItemType item_type,
45  DeviceIdentifier device_identifier,
46  size_t item_size,
47  size_t compute_time,
48  std::optional<EMPTY_META_INFO> meta_info) {
51  return;
52  }
54  std::lock_guard<std::mutex> lock(getCacheLock());
55  auto layout_cache = getCachedItemContainer(item_type, device_identifier);
56  auto param_cache = getCachedItem(key, *layout_cache);
57  if (param_cache) {
58  return;
59  }
60  layout_cache->emplace_back(key, item, nullptr, meta_info);
61  VLOG(1) << "[" << DataRecyclerUtil::toStringCacheItemType(item_type) << ", "
63  << "] Put auto tuner parameters for the overlaps hash join qual to cache";
64  return;
65 }
66 
68  QueryPlanHash key,
69  CacheItemType item_type,
70  DeviceIdentifier device_identifier,
71  std::lock_guard<std::mutex>& lock,
72  std::optional<EMPTY_META_INFO> meta_info) const {
75  return false;
76  }
78  auto layout_cache = getCachedItemContainer(item_type, device_identifier);
79  return getCachedItem(key, *layout_cache).has_value();
80 }
81 
83  std::lock_guard<std::mutex> lock(getCacheLock());
86  param_cache->clear();
87 }
88 
90  std::ostringstream oss;
91  oss << "A current status of the Overlaps Join Hashtable Tuning Parameter Recycler:\n";
92  oss << "\t# cached parameters:\n";
93  oss << "\t\tDevice" << PARAM_CACHE_DEVICE_IDENTIFIER << "\n";
95  PARAM_CACHE_DEVICE_IDENTIFIER);
96  for (auto& cache_container : *param_cache) {
97  oss << "\t\t\tCache_key: " << cache_container.key;
98  if (cache_container.cached_item.has_value()) {
99  oss << ", Max_hashtable_size: " << cache_container.cached_item->max_hashtable_size
100  << ", Bucket_threshold: " << cache_container.cached_item->bucket_threshold
101  << ", Bucket_sizes: " << ::toString(cache_container.cached_item->bucket_sizes)
102  << "\n";
103  } else {
104  oss << ", Params info is not available\n";
105  }
106  }
107  return oss.str();
108 }
#define CHECK_EQ(x, y)
Definition: Logger.h:217
size_t DeviceIdentifier
Definition: DataRecycler.h:111
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
Definition: DataRecycler.h:134
static std::string_view toStringCacheItemType(CacheItemType item_type)
Definition: DataRecycler.h:127
bool hasItemInCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) const override
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:446
bool g_enable_data_recycler
Definition: Execute.cpp:139
CacheItemType
Definition: DataRecycler.h:36
constexpr DeviceIdentifier PARAM_CACHE_DEVICE_IDENTIFIER
virtual std::optional< AutoTunerMetaInfo > getItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) const =0
size_t QueryPlanHash
std::optional< CachedItem< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO > > getCachedItem(QueryPlanHash key, CachedItemContainer &m) const
Definition: DataRecycler.h:460
std::string toString() const override
bool g_use_hashtable_cache
Definition: Execute.cpp:140
#define VLOG(n)
Definition: Logger.h:303
void putItemToCache(QueryPlanHash key, std::optional< AutoTunerMetaInfo > item, CacheItemType item_type, DeviceIdentifier device_identifier, size_t item_size, size_t compute_time, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override