OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE > Class Template Referenceabstract

#include <DataRecycler.h>

Public Types

using CachedItemContainer = std::vector< CachedItem< CACHED_ITEM_TYPE, META_INFO_TYPE >>
 
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 >
 

Public Member Functions

 DataRecycler (const std::vector< CacheItemType > &item_types, size_t total_cache_size, size_t max_item_size, int num_gpus)
 
virtual ~DataRecycler ()=default
 
virtual CACHED_ITEM_TYPE getItemFromCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
 
virtual void putItemToCache (QueryPlanHash key, CACHED_ITEM_TYPE item_ptr, CacheItemType item_type, DeviceIdentifier device_identifier, size_t item_size, size_t compute_time, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
 
virtual void initCache ()=0
 
virtual void clearCache ()=0
 
virtual void markCachedItemAsDirty (size_t table_key, std::unordered_set< QueryPlanHash > &key_set, CacheItemType item_type, DeviceIdentifier device_identifier)=0
 
void markCachedItemAsDirtyImpl (QueryPlanHash key, CachedItemContainer &m) const
 
bool isCachedItemDirty (QueryPlanHash key, CachedItemContainer &m) const
 
virtual std::string toString () const =0
 
std::shared_ptr
< CachedItemContainer
getCachedItemContainer (CacheItemType item_type, DeviceIdentifier device_identifier) const
 
std::optional< CachedItem
< CACHED_ITEM_TYPE,
META_INFO_TYPE > > 
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)
 

Protected Member Functions

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
 

Private Member Functions

virtual bool hasItemInCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< META_INFO_TYPE > meta_info=std::nullopt) const =0
 
virtual void removeItemFromCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
 
virtual void cleanupCacheForInsertion (CacheItemType item_type, DeviceIdentifier device_identifier, size_t required_size, std::lock_guard< std::mutex > &lock, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
 

Private Attributes

std::unordered_set< CacheItemTypecache_item_types_
 
PerTypeCacheMetricTracker metric_tracker_
 
PerTypeCacheItemContainer cached_items_container_
 
std::mutex cache_lock_
 

Detailed Description

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
class DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >

Definition at line 449 of file DataRecycler.h.

Member Typedef Documentation

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
using DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::CachedItemContainer = std::vector<CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE>>

Definition at line 451 of file DataRecycler.h.

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
using DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::PerDeviceCacheItemContainer = std::unordered_map<DeviceIdentifier, std::shared_ptr<CachedItemContainer>>

Definition at line 453 of file DataRecycler.h.

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
using DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::PerTypeCacheItemContainer = std::unordered_map<CacheItemType, std::shared_ptr<PerDeviceCacheItemContainer>>

Definition at line 455 of file DataRecycler.h.

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
using DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::PerTypeCacheMetricTracker = std::unordered_map<CacheItemType, CacheMetricTracker>

Definition at line 456 of file DataRecycler.h.

Constructor & Destructor Documentation

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::DataRecycler ( const std::vector< CacheItemType > &  item_types,
size_t  total_cache_size,
size_t  max_item_size,
int  num_gpus 
)
inline

Definition at line 458 of file DataRecycler.h.

461  {
462  for (auto& item_type : item_types) {
463  cache_item_types_.insert(item_type);
464  metric_tracker_.emplace(
465  item_type,
466  CacheMetricTracker(item_type, total_cache_size, max_item_size, num_gpus));
467  auto item_container = std::make_shared<PerDeviceCacheItemContainer>();
468  for (int gpu_device_identifier = num_gpus; gpu_device_identifier >= 1;
469  --gpu_device_identifier) {
470  item_container->emplace(gpu_device_identifier,
471  std::make_shared<CachedItemContainer>());
472  }
473  item_container->emplace(DataRecyclerUtil::CPU_DEVICE_IDENTIFIER,
474  std::make_shared<CachedItemContainer>());
475  cached_items_container_.emplace(item_type, item_container);
476  }
477  }
std::unordered_set< CacheItemType > cache_item_types_
Definition: DataRecycler.h:698
PerTypeCacheMetricTracker metric_tracker_
Definition: DataRecycler.h:701
PerTypeCacheItemContainer cached_items_container_
Definition: DataRecycler.h:704
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::~DataRecycler ( )
virtualdefault

Member Function Documentation

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::cleanupCacheForInsertion ( CacheItemType  item_type,
DeviceIdentifier  device_identifier,
size_t  required_size,
std::lock_guard< std::mutex > &  lock,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
)
privatepure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::clearCache ( )
pure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::shared_ptr<CachedItemContainer> DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCachedItemContainer ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 528 of file DataRecycler.h.

Referenced by DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCurrentNumCachedItems(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCurrentNumCleanCachedItems(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCurrentNumDirtyCachedItems(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::removeCachedItemFromBeginning(), and DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::sortCacheContainerByQueryMetric().

530  {
531  auto item_type_container_itr = cached_items_container_.find(item_type);
532  if (item_type_container_itr != cached_items_container_.end()) {
533  auto device_type_container_itr =
534  item_type_container_itr->second->find(device_identifier);
535  return device_type_container_itr != item_type_container_itr->second->end()
536  ? device_type_container_itr->second
537  : nullptr;
538  }
539  return nullptr;
540  }
PerTypeCacheItemContainer cached_items_container_
Definition: DataRecycler.h:704

+ Here is the caller graph for this function:

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::shared_ptr<CacheItemMetric> DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCachedItemMetric ( CacheItemType  item_type,
DeviceIdentifier  device_identifier,
QueryPlanHash  key 
) const
inline

Definition at line 598 of file DataRecycler.h.

600  {
601  std::lock_guard<std::mutex> lock(cache_lock_);
602  auto cache_metric_tracker = getMetricTracker(item_type);
603  return cache_metric_tracker.getCacheItemMetric(key, device_identifier);
604  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:654
std::mutex cache_lock_
Definition: DataRecycler.h:706
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::optional<CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE> > DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCachedItemWithoutConsideringMetaInfo ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
CachedItemContainer m,
std::lock_guard< std::mutex > &  lock 
)
inline

Definition at line 543 of file DataRecycler.h.

547  {
548  auto candidate_it = std::find_if(
549  m.begin(),
550  m.end(),
551  [&key](const CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE>& cached_item) {
552  return cached_item.key == key;
553  });
554  if (candidate_it != m.end()) {
555  if (candidate_it->isDirty()) {
557  key, item_type, device_identifier, lock, candidate_it->meta_info);
558  return std::nullopt;
559  }
560  return *candidate_it;
561  }
562  return std::nullopt;
563  }
virtual void removeItemFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier, std::lock_guard< std::mutex > &lock, std::optional< META_INFO_TYPE > meta_info=std::nullopt)=0
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::unordered_set<CacheItemType> const& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCacheItemType ( ) const
inlineprotected

Definition at line 664 of file DataRecycler.h.

664  {
665  return cache_item_types_;
666  }
std::unordered_set< CacheItemType > cache_item_types_
Definition: DataRecycler.h:698
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::mutex& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCacheLock ( ) const
inlineprotected

Definition at line 652 of file DataRecycler.h.

652 { return cache_lock_; }
std::mutex cache_lock_
Definition: DataRecycler.h:706
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
size_t DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCurrentCacheSizeForDevice ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 590 of file DataRecycler.h.

Referenced by anonymous_namespace{DBHandler.cpp}::log_cache_size().

591  {
592  std::lock_guard<std::mutex> lock(cache_lock_);
593  auto metric_tracker = getMetricTracker(item_type);
594  auto current_size_opt = metric_tracker.getCurrentCacheSize(device_identifier);
595  return current_size_opt ? current_size_opt.value() : 0;
596  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:654
std::mutex cache_lock_
Definition: DataRecycler.h:706

+ Here is the caller graph for this function:

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
size_t DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCurrentNumCachedItems ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 565 of file DataRecycler.h.

566  {
567  std::lock_guard<std::mutex> lock(cache_lock_);
568  auto container = getCachedItemContainer(item_type, device_identifier);
569  return container ? container->size() : 0;
570  }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
std::mutex cache_lock_
Definition: DataRecycler.h:706
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
size_t DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCurrentNumCleanCachedItems ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 581 of file DataRecycler.h.

582  {
583  std::lock_guard<std::mutex> lock(cache_lock_);
584  auto container = getCachedItemContainer(item_type, device_identifier);
585  return std::count_if(container->begin(),
586  container->end(),
587  [](const auto& cached_item) { return !cached_item.isDirty(); });
588  }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
std::mutex cache_lock_
Definition: DataRecycler.h:706
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
size_t DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getCurrentNumDirtyCachedItems ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
) const
inline

Definition at line 572 of file DataRecycler.h.

573  {
574  std::lock_guard<std::mutex> lock(cache_lock_);
575  auto container = getCachedItemContainer(item_type, device_identifier);
576  return std::count_if(container->begin(),
577  container->end(),
578  [](const auto& cached_item) { return cached_item.isDirty(); });
579  }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
std::mutex cache_lock_
Definition: DataRecycler.h:706
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
PerTypeCacheItemContainer const& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getItemCache ( ) const
inlineprotected

Definition at line 668 of file DataRecycler.h.

668  {
670  }
PerTypeCacheItemContainer cached_items_container_
Definition: DataRecycler.h:704
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual CACHED_ITEM_TYPE DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getItemFromCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
)
pure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
CacheMetricTracker& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getMetricTracker ( CacheItemType  item_type)
inlineprotected

Definition at line 654 of file DataRecycler.h.

Referenced by DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCachedItemMetric(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCurrentCacheSizeForDevice(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getMetricTracker(), DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::setMaxCacheItemSize(), and DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::setTotalCacheSize().

654  {
655  auto metric_iter = metric_tracker_.find(item_type);
656  CHECK(metric_iter != metric_tracker_.end());
657  return metric_iter->second;
658  }
PerTypeCacheMetricTracker metric_tracker_
Definition: DataRecycler.h:701
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
CacheMetricTracker const& DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::getMetricTracker ( CacheItemType  item_type) const
inlineprotected

Definition at line 660 of file DataRecycler.h.

660  {
661  return const_cast<DataRecycler*>(this)->getMetricTracker(item_type);
662  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:654
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual bool DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::hasItemInCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::lock_guard< std::mutex > &  lock,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
) const
privatepure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::initCache ( )
pure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
bool DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::isCachedItemDirty ( QueryPlanHash  key,
CachedItemContainer m 
) const
inline

Definition at line 516 of file DataRecycler.h.

516  {
517  auto candidate_it = std::find_if(
518  m.begin(),
519  m.end(),
520  [&key](const CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE>& cached_item) {
521  return cached_item.key == key;
522  });
523  return candidate_it != m.end() && candidate_it->isDirty();
524  }
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::markCachedItemAsDirty ( size_t  table_key,
std::unordered_set< QueryPlanHash > &  key_set,
CacheItemType  item_type,
DeviceIdentifier  device_identifier 
)
pure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::markCachedItemAsDirtyImpl ( QueryPlanHash  key,
CachedItemContainer m 
) const
inline

Definition at line 504 of file DataRecycler.h.

504  {
505  auto candidate_it = std::find_if(
506  m.begin(),
507  m.end(),
508  [&key](const CachedItem<CACHED_ITEM_TYPE, META_INFO_TYPE>& cached_item) {
509  return cached_item.key == key;
510  });
511  if (candidate_it != m.end()) {
512  candidate_it->setDirty();
513  }
514  }
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::putItemToCache ( QueryPlanHash  key,
CACHED_ITEM_TYPE  item_ptr,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
size_t  item_size,
size_t  compute_time,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
)
pure virtual
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::removeCachedItemFromBeginning ( CacheItemType  item_type,
DeviceIdentifier  device_identifier,
int  offset 
)
inlineprotected

Definition at line 621 of file DataRecycler.h.

623  {
624  // it removes cached items located from `idx 0` to `offset`
625  // so, call this function after sorting the cached items container vec
626  // and we should call this function under the proper locking scheme
627  auto container = getCachedItemContainer(item_type, device_identifier);
628  CHECK(container);
629  container->erase(container->begin(), container->begin() + offset);
630  }
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
#define CHECK(condition)
Definition: Logger.h:291
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::removeItemFromCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier,
std::lock_guard< std::mutex > &  lock,
std::optional< META_INFO_TYPE >  meta_info = std::nullopt 
)
privatepure virtual

Implemented in HashtableRecycler, ResultSetRecycler, ChunkMetadataRecycler, BoundingBoxIntersectTuningParamRecycler, and HashingSchemeRecycler.

Referenced by DataRecycler< std::optional< HashType >, EMPTY_META_INFO >::getCachedItemWithoutConsideringMetaInfo().

+ Here is the caller graph for this function:

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::setMaxCacheItemSize ( CacheItemType  item_type,
size_t  new_max_cache_item_size 
)
inline

Definition at line 613 of file DataRecycler.h.

Referenced by CommandLineOptions::parse_command_line().

613  {
614  if (new_max_cache_item_size > 0) {
615  std::lock_guard<std::mutex> lock(cache_lock_);
616  getMetricTracker(item_type).setMaxCacheItemSize(new_max_cache_item_size);
617  }
618  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:654
void setMaxCacheItemSize(size_t new_max_cache_item_size)
Definition: DataRecycler.h:401
std::mutex cache_lock_
Definition: DataRecycler.h:706

+ Here is the caller graph for this function:

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::setTotalCacheSize ( CacheItemType  item_type,
size_t  new_total_cache_size 
)
inline

Definition at line 606 of file DataRecycler.h.

Referenced by CommandLineOptions::parse_command_line().

606  {
607  if (new_total_cache_size > 0) {
608  std::lock_guard<std::mutex> lock(cache_lock_);
609  getMetricTracker(item_type).setTotalCacheSize(new_total_cache_size);
610  }
611  }
CacheMetricTracker & getMetricTracker(CacheItemType item_type)
Definition: DataRecycler.h:654
std::mutex cache_lock_
Definition: DataRecycler.h:706
void setTotalCacheSize(size_t new_total_cache_size)
Definition: DataRecycler.h:396

+ Here is the caller graph for this function:

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
void DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::sortCacheContainerByQueryMetric ( CacheItemType  item_type,
DeviceIdentifier  device_identifier 
)
inlineprotected

Definition at line 632 of file DataRecycler.h.

633  {
634  // should call this function under the proper locking scheme
635  auto container = getCachedItemContainer(item_type, device_identifier);
636  CHECK(container);
637  std::sort(container->begin(),
638  container->end(),
641  auto& left_metrics = left.item_metric->getMetrics();
642  auto& right_metrics = right.item_metric->getMetrics();
643  for (size_t i = 0; i < CacheMetricType::NUM_METRIC_TYPE; ++i) {
644  if (left_metrics[i] != right_metrics[i]) {
645  return left_metrics[i] < right_metrics[i];
646  }
647  }
648  return false;
649  });
650  }
DEVICE void sort(ARGS &&...args)
Definition: gpu_enabled.h:105
std::shared_ptr< CachedItemContainer > getCachedItemContainer(CacheItemType item_type, DeviceIdentifier device_identifier) const
Definition: DataRecycler.h:528
#define CHECK(condition)
Definition: Logger.h:291
std::shared_ptr< CacheItemMetric > item_metric
Definition: DataRecycler.h:438
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
virtual std::string DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::toString ( ) const
pure virtual

Member Data Documentation

template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
std::unordered_set<CacheItemType> DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::cache_item_types_
private
template<typename CACHED_ITEM_TYPE, typename META_INFO_TYPE>
PerTypeCacheMetricTracker DataRecycler< CACHED_ITEM_TYPE, META_INFO_TYPE >::metric_tracker_
private

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