OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OverlapsTuningParamRecycler Class Reference

#include <OverlapsTuningParamRecycler.h>

+ Inheritance diagram for OverlapsTuningParamRecycler:
+ Collaboration diagram for OverlapsTuningParamRecycler:

Public Member Functions

 OverlapsTuningParamRecycler ()
 
 std::numeric_limits ()
 
 std::numeric_limits ()
 
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
 
void initCache () override
 
void clearCache () override
 
void markCachedItemAsDirty (size_t table_key, std::unordered_set< QueryPlanHash > &key_set, CacheItemType item_type, DeviceIdentifier device_identifier) override
 
std::string toString () const override
 
- Public Member Functions inherited from DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >
 DataRecycler (const std::vector< CacheItemType > &item_types, size_t total_cache_size, size_t max_item_size, int num_gpus)
 
virtual ~DataRecycler ()=default
 
virtual std::optional
< AutoTunerMetaInfo
getItemFromCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< EMPTY_META_INFO > meta_info=std::nullopt)=0
 
void markCachedItemAsDirtyImpl (QueryPlanHash key, CachedItemContainer &m) const
 
bool isCachedItemDirty (QueryPlanHash key, CachedItemContainer &m) const
 
std::shared_ptr
< CachedItemContainer
getCachedItemContainer (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
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)
 
size_t getCurrentNumCachedItems (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
size_t getCurrentNumDirtyCachedItems (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
size_t getCurrentNumCleanCachedItems (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
size_t getCurrentCacheSizeForDevice (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
std::shared_ptr< CacheItemMetricgetCachedItemMetric (CacheItemType item_type, DeviceIdentifier device_identifier, QueryPlanHash key) const
 
void setTotalCacheSize (CacheItemType item_type, size_t new_total_cache_size)
 
void setMaxCacheItemSize (CacheItemType item_type, size_t new_max_cache_item_size)
 

Private Member Functions

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
 
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
 
void cleanupCacheForInsertion (CacheItemType item_type, DeviceIdentifier device_identifier, size_t required_size, std::lock_guard< std::mutex > &lock, std::optional< EMPTY_META_INFO > meta_info=std::nullopt) override
 

Additional Inherited Members

- Public Types inherited from DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >
using CachedItemContainer = std::vector< CachedItem< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >>
 
using PerDeviceCacheItemContainer = std::unordered_map< DeviceIdentifier, std::shared_ptr< CachedItemContainer >>
 
using PerTypeCacheItemContainer = std::unordered_map< CacheItemType, std::shared_ptr< PerDeviceCacheItemContainer >>
 
using PerTypeCacheMetricTracker = std::unordered_map< CacheItemType, CacheMetricTracker >
 
- Protected Member Functions inherited from DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >
void removeCachedItemFromBeginning (CacheItemType item_type, DeviceIdentifier device_identifier, int offset)
 
void sortCacheContainerByQueryMetric (CacheItemType item_type, DeviceIdentifier device_identifier)
 
std::mutex & getCacheLock () const
 
CacheMetricTrackergetMetricTracker (CacheItemType item_type)
 
CacheMetricTracker const & getMetricTracker (CacheItemType item_type) const
 
std::unordered_set
< CacheItemType > const & 
getCacheItemType () const
 
PerTypeCacheItemContainer const & getItemCache () const
 

Detailed Description

Definition at line 32 of file OverlapsTuningParamRecycler.h.

Constructor & Destructor Documentation

OverlapsTuningParamRecycler::OverlapsTuningParamRecycler ( )
inline

Definition at line 38 of file OverlapsTuningParamRecycler.h.

References OVERLAPS_AUTO_TUNER_PARAM.

DataRecycler(const std::vector< CacheItemType > &item_types, size_t total_cache_size, size_t max_item_size, int num_gpus)
Definition: DataRecycler.h:458

Member Function Documentation

void OverlapsTuningParamRecycler::cleanupCacheForInsertion ( CacheItemType  item_type,
DeviceIdentifier  device_identifier,
size_t  required_size,
std::lock_guard< std::mutex > &  lock,
std::optional< EMPTY_META_INFO meta_info = std::nullopt 
)
inlineoverrideprivatevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 87 of file OverlapsTuningParamRecycler.h.

References UNREACHABLE.

92  {
93  UNREACHABLE();
94  }
#define UNREACHABLE()
Definition: Logger.h:337
void OverlapsTuningParamRecycler::clearCache ( )
overridevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 108 of file OverlapsTuningParamRecycler.cpp.

References DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCacheLock(), DataRecyclerUtil::getDeviceIdentifierString(), OVERLAPS_AUTO_TUNER_PARAM, PARAM_CACHE_DEVICE_IDENTIFIER, and VLOG.

108  {
109  std::lock_guard<std::mutex> lock(getCacheLock());
112  if (!param_cache->empty()) {
115  << "] clear cache (# items: " << param_cache->size() << ")";
116  param_cache->clear();
117  }
118 }
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
Definition: DataRecycler.h:138
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
constexpr DeviceIdentifier PARAM_CACHE_DEVICE_IDENTIFIER
#define VLOG(n)
Definition: Logger.h:387

+ Here is the call graph for this function:

bool OverlapsTuningParamRecycler::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
overrideprivatevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 70 of file OverlapsTuningParamRecycler.cpp.

References CHECK_EQ, EMPTY_HASHED_PLAN_DAG_KEY, g_enable_data_recycler, g_use_hashtable_cache, DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), and OVERLAPS_AUTO_TUNER_PARAM.

75  {
78  return false;
79  }
81  auto param_cache = getCachedItemContainer(item_type, device_identifier);
82  auto candidate_it = std::find_if(
83  param_cache->begin(), param_cache->end(), [&key](const auto& cached_item) {
84  return cached_item.key == key;
85  });
86  return candidate_it != param_cache->end();
87 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
bool g_enable_data_recycler
Definition: Execute.cpp:146
bool g_use_hashtable_cache
Definition: Execute.cpp:147

+ Here is the call graph for this function:

void OverlapsTuningParamRecycler::initCache ( )
inlineoverridevirtual
void OverlapsTuningParamRecycler::markCachedItemAsDirty ( size_t  table_key,
std::unordered_set< QueryPlanHash > &  key_set,
CacheItemType  item_type,
DeviceIdentifier  device_identifier 
)
overridevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 120 of file OverlapsTuningParamRecycler.cpp.

References CHECK_EQ, g_enable_data_recycler, g_use_hashtable_cache, DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCacheLock(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::markCachedItemAsDirtyImpl(), and OVERLAPS_AUTO_TUNER_PARAM.

124  {
125  if (!g_enable_data_recycler || !g_use_hashtable_cache || key_set.empty()) {
126  return;
127  }
129  std::lock_guard<std::mutex> lock(getCacheLock());
130  auto param_cache = getCachedItemContainer(item_type, device_identifier);
131  for (auto key : key_set) {
132  markCachedItemAsDirtyImpl(key, *param_cache);
133  }
134 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
void markCachedItemAsDirtyImpl(QueryPlanHash key, CachedItemContainer &m) const
Definition: DataRecycler.h:504
bool g_enable_data_recycler
Definition: Execute.cpp:146
bool g_use_hashtable_cache
Definition: Execute.cpp:147

+ Here is the call graph for this function:

void OverlapsTuningParamRecycler::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 
)
overridevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 43 of file OverlapsTuningParamRecycler.cpp.

References CHECK_EQ, EMPTY_HASHED_PLAN_DAG_KEY, g_enable_data_recycler, g_use_hashtable_cache, DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemWithoutConsideringMetaInfo(), DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCacheLock(), DataRecyclerUtil::getDeviceIdentifierString(), OVERLAPS_AUTO_TUNER_PARAM, and VLOG.

50  {
53  return;
54  }
56  std::lock_guard<std::mutex> lock(getCacheLock());
57  auto param_cache = getCachedItemContainer(item_type, device_identifier);
58  auto cached_param = getCachedItemWithoutConsideringMetaInfo(
59  key, item_type, device_identifier, *param_cache, lock);
60  if (cached_param) {
61  return;
62  }
63  param_cache->emplace_back(key, item, nullptr, meta_info);
64  VLOG(1) << "[" << item_type << ", "
66  << "] Put auto tuner parameters to cache (key: " << key << ")";
67  return;
68 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
Definition: DataRecycler.h:138
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)
Definition: DataRecycler.h:543
constexpr QueryPlanHash EMPTY_HASHED_PLAN_DAG_KEY
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
bool g_enable_data_recycler
Definition: Execute.cpp:146
bool g_use_hashtable_cache
Definition: Execute.cpp:147
#define VLOG(n)
Definition: Logger.h:387

+ Here is the call graph for this function:

void OverlapsTuningParamRecycler::removeItemFromCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::lock_guard< std::mutex > &  lock,
std::optional< EMPTY_META_INFO meta_info = std::nullopt 
)
overrideprivatevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 89 of file OverlapsTuningParamRecycler.cpp.

References DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), DataRecyclerUtil::getDeviceIdentifierString(), and VLOG.

94  {
95  auto param_cache = getCachedItemContainer(item_type, device_identifier);
96  auto filter = [key](auto const& item) { return item.key == key; };
97  auto itr = std::find_if(param_cache->cbegin(), param_cache->cend(), filter);
98  if (itr == param_cache->cend()) {
99  return;
100  } else {
101  VLOG(1) << "[" << item_type << ", "
102  << DataRecyclerUtil::getDeviceIdentifierString(device_identifier)
103  << "] remove cached item from cache (key: " << key << ")";
104  param_cache->erase(itr);
105  }
106 }
static std::string getDeviceIdentifierString(DeviceIdentifier device_identifier)
Definition: DataRecycler.h:138
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
#define VLOG(n)
Definition: Logger.h:387

+ Here is the call graph for this function:

OverlapsTuningParamRecycler::std::numeric_limits ( )
OverlapsTuningParamRecycler::std::numeric_limits ( )
std::string OverlapsTuningParamRecycler::toString ( ) const
overridevirtual

Implements DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >.

Definition at line 136 of file OverlapsTuningParamRecycler.cpp.

References DataRecycler< std::optional< AutoTunerMetaInfo >, EMPTY_META_INFO >::getCachedItemContainer(), OVERLAPS_AUTO_TUNER_PARAM, and PARAM_CACHE_DEVICE_IDENTIFIER.

136  {
137  std::ostringstream oss;
138  oss << "A current status of the Overlaps Join Hashtable Tuning Parameter Recycler:\n";
139  oss << "\t# cached parameters:\n";
140  oss << "\t\tDevice" << PARAM_CACHE_DEVICE_IDENTIFIER << "\n";
142  PARAM_CACHE_DEVICE_IDENTIFIER);
143  for (auto& cache_container : *param_cache) {
144  oss << "\t\t\tCache_key: " << cache_container.key;
145  if (cache_container.cached_item.has_value()) {
146  oss << ", Max_hashtable_size: " << cache_container.cached_item->max_hashtable_size
147  << ", Bucket_threshold: " << cache_container.cached_item->bucket_threshold
148  << ", Bucket_sizes: " << ::toString(cache_container.cached_item->bucket_sizes)
149  << "\n";
150  } else {
151  oss << ", Params info is not available\n";
152  }
153  }
154  return oss.str();
155 }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
constexpr DeviceIdentifier PARAM_CACHE_DEVICE_IDENTIFIER
std::string toString() const override

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: