diff --git a/src/IStorage.h b/src/IStorage.h index 5bf583804..cdb8336f4 100644 --- a/src/IStorage.h +++ b/src/IStorage.h @@ -22,7 +22,7 @@ public: virtual void retrieve(const char *key, size_t cchKey, callbackSingle fn) const = 0; virtual size_t clear() = 0; virtual bool enumerate(callback fn) const = 0; - virtual size_t count(bool fStrict) const = 0; + virtual size_t count() const = 0; virtual void beginWriteBatch() {} // NOP virtual void endWriteBatch() {} // NOP diff --git a/src/db.cpp b/src/db.cpp index 35fb73500..f5c8c68cc 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -2195,7 +2195,7 @@ dict_iter redisDbPersistentData::random() size_t redisDbPersistentData::size() const { if (m_spstorage != nullptr) - return m_spstorage->count(false); + return m_spstorage->count(); return dictSize(m_pdict) + (m_pdbSnapshot ? (m_pdbSnapshot->size() - dictSize(m_pdictTombstone)) : 0); diff --git a/src/evict.cpp b/src/evict.cpp index 10952c73f..038542365 100644 --- a/src/evict.cpp +++ b/src/evict.cpp @@ -492,14 +492,6 @@ int freeMemoryIfNeeded(void) { mem_freed = 0; - size_t maxKeys = 0; - size_t totalKeysFreed = 0; - for (int i = 0; i < cserver.dbnum; ++i) - maxKeys += g_pserver->db[i]->size(); - - // A random search is n log n, so if we run longer than this we know we're not going to terminate - maxKeys = static_cast(maxKeys * (log2(maxKeys))); - if (g_pserver->maxmemory_policy == MAXMEMORY_NO_EVICTION) goto cant_free; /* We need to free memory, but policy forbids. */ @@ -640,7 +632,6 @@ int freeMemoryIfNeeded(void) { } keys_freed++; - totalKeysFreed++; /* When the memory to free starts to be big enough, we may * start spending so much time here that is impossible to @@ -663,16 +654,6 @@ int freeMemoryIfNeeded(void) { } } - // When using FLASH we're not actually evicting and we leave around the key - // its possible we tried to evict the whole database and failed to free enough memory - // quit if this happens - if (totalKeysFreed >= maxKeys) - { - latencyEndMonitor(latency); - latencyAddSampleIfNeeded("eviction-cycle",latency); - goto cant_free; - } - if (keys_freed <= 0) { latencyEndMonitor(latency); latencyAddSampleIfNeeded("eviction-cycle",latency);