mirror of https://gitee.com/bigwinds/arangodb
Added sizeHint method for caches to improve warmup procedures.
This commit is contained in:
parent
0b8546ca98
commit
5ec026b659
|
@ -115,6 +115,15 @@ uint64_t Cache::usage() {
|
||||||
return usage;
|
return usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cache::sizeHint(uint64_t numElements) {
|
||||||
|
uint64_t numBuckets = static_cast<uint64_t>(static_cast<double>(numElements)
|
||||||
|
/ (static_cast<double>(_slotsPerBucket) * Table::idealUpperRatio));
|
||||||
|
uint32_t requestedLogSize = 0;
|
||||||
|
for (; (static_cast<uint64_t>(1) << requestedLogSize) < numBuckets;
|
||||||
|
requestedLogSize++) {}
|
||||||
|
requestMigrate(requestedLogSize);
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<double, double> Cache::hitRates() {
|
std::pair<double, double> Cache::hitRates() {
|
||||||
double lifetimeRate = std::nan("");
|
double lifetimeRate = std::nan("");
|
||||||
double windowedRate = std::nan("");
|
double windowedRate = std::nan("");
|
||||||
|
|
|
@ -97,6 +97,14 @@ class Cache : public std::enable_shared_from_this<Cache> {
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
uint64_t usage();
|
uint64_t usage();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief Gives hint to attempt to preallocate space for an incoming load.
|
||||||
|
///
|
||||||
|
/// The parameter specifies an expected number of elements to be inserted.
|
||||||
|
/// This allows for migration to an appropriately-sized table.
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
void sizeHint(uint64_t numElements);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Returns the cache hit-rates.
|
/// @brief Returns the cache hit-rates.
|
||||||
///
|
///
|
||||||
|
|
|
@ -39,6 +39,8 @@ namespace cache {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
class Table : public std::enable_shared_from_this<Table> {
|
class Table : public std::enable_shared_from_this<Table> {
|
||||||
public:
|
public:
|
||||||
|
static constexpr double idealLowerRatio = 0.05;
|
||||||
|
static constexpr double idealUpperRatio = 0.33;
|
||||||
static const uint32_t minLogSize;
|
static const uint32_t minLogSize;
|
||||||
static const uint32_t maxLogSize;
|
static const uint32_t maxLogSize;
|
||||||
static constexpr uint32_t standardLogSizeAdjustment = 6;
|
static constexpr uint32_t standardLogSizeAdjustment = 6;
|
||||||
|
@ -186,9 +188,6 @@ class Table : public std::enable_shared_from_this<Table> {
|
||||||
uint32_t idealSize();
|
uint32_t idealSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr double idealLowerRatio = 0.05;
|
|
||||||
static constexpr double idealUpperRatio = 0.33;
|
|
||||||
|
|
||||||
State _state;
|
State _state;
|
||||||
|
|
||||||
uint32_t _logSize;
|
uint32_t _logSize;
|
||||||
|
|
Loading…
Reference in New Issue