mirror of https://gitee.com/bigwinds/arangodb
Added hinting so cache table is aware of eviction rate problems.
This commit is contained in:
parent
78c80c3a3d
commit
71846d0ad7
|
@ -283,6 +283,11 @@ bool Cache::reportInsert(bool hadEviction) {
|
|||
if (((++_insertsTotal) & _evictionMask) == 0) {
|
||||
if (_insertEvictions.load() > _evictionThreshold) {
|
||||
shouldMigrate = true;
|
||||
bool ok = _state.lock(triesGuarantee);
|
||||
if (ok) {
|
||||
_table->signalEvictions();
|
||||
_state.unlock();
|
||||
}
|
||||
}
|
||||
_insertEvictions = 0;
|
||||
}
|
||||
|
|
|
@ -59,12 +59,13 @@ struct State {
|
|||
locked = 0x00000001,
|
||||
blacklisted = 0x00000002,
|
||||
disabled = 0x00000004,
|
||||
migrated = 0x00000008,
|
||||
migrating = 0x00000010,
|
||||
rebalancing = 0x00000020,
|
||||
resizing = 0x00000040,
|
||||
shutdown = 0x00000080,
|
||||
shuttingDown = 0x00000100
|
||||
evictions = 0x00000008,
|
||||
migrated = 0x00000010,
|
||||
migrating = 0x00000020,
|
||||
rebalancing = 0x00000040,
|
||||
resizing = 0x00000080,
|
||||
shutdown = 0x00000100,
|
||||
shuttingDown = 0x00000200,
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -243,7 +243,30 @@ bool Table::slotEmptied() {
|
|||
(_logSize > Table::minLogSize));
|
||||
}
|
||||
|
||||
uint32_t Table::idealSize() const {
|
||||
void Table::signalEvictions() {
|
||||
bool ok = _state.lock(triesGuarantee);
|
||||
if (ok) {
|
||||
if (!_state.isSet(State::Flag::evictions)) {
|
||||
_state.toggleFlag(State::Flag::evictions);
|
||||
}
|
||||
_state.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Table::idealSize() {
|
||||
bool ok = _state.lock(triesGuarantee);
|
||||
bool forceGrowth = false;
|
||||
if (ok) {
|
||||
forceGrowth = _state.isSet(State::Flag::evictions);
|
||||
if (forceGrowth) {
|
||||
_state.toggleFlag(State::Flag::evictions);
|
||||
}
|
||||
_state.unlock();
|
||||
}
|
||||
if (forceGrowth) {
|
||||
return logSize() + 1;
|
||||
}
|
||||
|
||||
return (((static_cast<double>(_slotsUsed.load()) /
|
||||
static_cast<double>(_slotsTotal)) > Table::idealUpperRatio)
|
||||
? (logSize() + 1)
|
||||
|
|
|
@ -173,10 +173,17 @@ class Table : public std::enable_shared_from_this<Table> {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
bool slotEmptied();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Report that there have been too many evictions.
|
||||
///
|
||||
/// Will force a subsequent idealSize() call to return a larger table size.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void signalEvictions();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the ideal size of the table based on fill ratio.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
uint32_t idealSize() const;
|
||||
uint32_t idealSize();
|
||||
|
||||
private:
|
||||
static constexpr double idealLowerRatio = 0.05;
|
||||
|
|
Loading…
Reference in New Issue