19 std::optional<AutoTunerMetaInfo>
24 std::optional<EMPTY_META_INFO> meta_info) {
33 key, item_type, device_identifier, *param_cache, lock);
35 CHECK(!cached_param->isDirty());
36 VLOG(1) <<
"[" << item_type <<
", "
38 <<
"] Recycle auto tuner parameters in cache (key: " << key <<
")";
39 return cached_param->cached_item;
46 std::optional<AutoTunerMetaInfo> item,
51 std::optional<EMPTY_META_INFO> meta_info) {
60 key, item_type, device_identifier, *param_cache, lock);
64 param_cache->emplace_back(key, item,
nullptr, meta_info);
65 VLOG(1) <<
"[" << item_type <<
", "
67 <<
"] Put auto tuner parameters to cache (key: " << key <<
")";
75 std::lock_guard<std::mutex>& lock,
76 std::optional<EMPTY_META_INFO> meta_info)
const {
83 auto candidate_it = std::find_if(
84 param_cache->begin(), param_cache->end(), [&key](
const auto& cached_item) {
85 return cached_item.key == key;
87 return candidate_it != param_cache->end();
94 std::lock_guard<std::mutex>& lock,
95 std::optional<EMPTY_META_INFO> meta_info) {
97 auto filter = [key](
auto const& item) {
return item.key == key; };
98 auto itr = std::find_if(param_cache->cbegin(), param_cache->cend(), filter);
99 if (itr == param_cache->cend()) {
102 VLOG(1) <<
"[" << item_type <<
", "
104 <<
"] remove cached item from cache (key: " << key <<
")";
105 param_cache->erase(itr);
113 if (!param_cache->empty()) {
116 <<
"] clear cache (# items: " << param_cache->size() <<
")";
117 param_cache->clear();
123 std::unordered_set<QueryPlanHash>& key_set,
132 for (
auto key : key_set) {
138 std::ostringstream oss;
139 oss <<
"A current status of the Bounding Box Intersection Tuning Parameter Recycler:\n";
140 oss <<
"\t# cached parameters:\n";
144 for (
auto& cache_container : *param_cache) {
145 oss <<
"\t\t\tCache_key: " << cache_container.key;
146 if (cache_container.cached_item.has_value()) {
147 oss <<
", Max_hashtable_size: " << cache_container.cached_item->max_hashtable_size
148 <<
", Bucket_threshold: " << cache_container.cached_item->bucket_threshold
149 <<
", Bucket_sizes: " <<
::toString(cache_container.cached_item->bucket_sizes)
152 oss <<
", Params info is not available\n";
std::mutex & getCacheLock() const
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
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
std::optional< CachedItem< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO > > getCachedItemWithoutConsideringMetaInfo(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, CachedItemContainer &m, std::lock_guard< std::mutex > &lock)
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
void markCachedItemAsDirtyImpl(QueryPlanHash key, CachedItemContainer &m) const
void clearCache() override
bool g_enable_data_recycler
void removeItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
constexpr DeviceIdentifier PARAM_CACHE_DEVICE_IDENTIFIER
void markCachedItemAsDirty(size_t table_key, std::unordered_set< QueryPlanHash > &key_set, CacheItemType item_type, DeviceIdentifier device_identifier) override
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
std::optional< AutoTunerMetaInfo > getItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
std::string toString() const override
bool g_use_hashtable_cache