Thread-aware FIFO cache for DMatrix related data.
More...
#include <cache.h>
|
| DMatrixCache (std::size_t cache_size) |
|
DMatrixCache & | operator= (DMatrixCache &&that) |
|
template<typename... Args> |
std::shared_ptr< CacheT > | CacheItem (std::shared_ptr< DMatrix > m, Args const &... args) |
| Cache a new DMatrix if it's not in the cache already.
|
|
template<typename... Args> |
std::shared_ptr< CacheT > | ResetItem (std::shared_ptr< DMatrix > m, Args const &... args) |
| Re-initialize the item in cache.
|
|
decltype(container_) const & | Container () |
| Get a const reference to the underlying hash map.
|
|
std::shared_ptr< CacheT > | Entry (DMatrix const *m) const |
|
|
static constexpr std::size_t | DefaultSize () |
|
|
void | CheckConsistent () const |
|
void | ClearExpired () |
|
void | ClearExcess () |
|
|
std::unordered_map< Key, Item, Hash > | container_ |
|
std::queue< Key > | queue_ |
|
std::size_t | max_size_ |
|
template<typename CacheT>
class xgboost::DMatrixCache< CacheT >
Thread-aware FIFO cache for DMatrix related data.
- Template Parameters
-
CacheT | The type that needs to be cached. |
◆ DMatrixCache()
template<typename CacheT >
- Parameters
-
cache_size | Maximum size of the cache. |
◆ CacheItem()
template<typename CacheT >
template<typename... Args>
Cache a new DMatrix if it's not in the cache already.
Passing in a shared_ptr
is critical here. First to create a weak_ptr
inside the entry this shared pointer is necessary. More importantly, the life time of this cache is tied to the shared pointer.
- Parameters
-
m | shared pointer to the DMatrix that needs to be cached. |
args | The arguments for constructing a new cache item, if needed. |
- Returns
- The cache entry for passed in DMatrix, either an existing cache or newly created.
◆ Container()
template<typename CacheT >
Get a const reference to the underlying hash map.
Clear expired caches before returning.
◆ ResetItem()
template<typename CacheT >
template<typename... Args>
Re-initialize the item in cache.
Since the shared_ptr is used to hold the item, any reference that lives outside of the cache can no-longer be reached from the cache.
We use reset instead of erase to avoid walking through the whole cache for renewing a single item. (the cache is FIFO, needs to maintain the order).
The documentation for this class was generated from the following file:
- External/xgboost/include/xgboost/cache.h