MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / freeMemoryGetNotCountedMemory

Function freeMemoryGetNotCountedMemory

src/evict.cpp:343–369  ·  view source on GitHub ↗

We don't want to count AOF buffers and slaves output buffers as * used memory: the eviction should use mostly data size. This function * returns the sum of AOF and slaves buffer. */

Source from the content-addressed store, hash-verified

341 * used memory: the eviction should use mostly data size. This function
342 * returns the sum of AOF and slaves buffer. */
343size_t freeMemoryGetNotCountedMemory(void) {
344 serverAssert(GlobalLocksAcquired());
345 size_t overhead = 0;
346 int slaves = listLength(g_pserver->slaves);
347
348 if (slaves) {
349 listIter li;
350 listNode *ln;
351
352 listRewind(g_pserver->slaves,&li);
353 while((ln = listNext(&li))) {
354 client *replica = (client*)listNodeValue(ln);
355 std::unique_lock<fastlock>(replica->lock);
356 /* we don't wish to multiple count the replication backlog shared usage */
357 overhead += (getClientOutputBufferMemoryUsage(replica) - getClientReplicationBacklogSharedUsage(replica));
358 }
359 }
360
361 /* also don't count the replication backlog memory
362 * that's where the replication clients get their memory from */
363 overhead += g_pserver->repl_backlog_size - g_pserver->repl_backlog_config_size;
364
365 if (g_pserver->aof_state != AOF_OFF) {
366 overhead += sdsalloc(g_pserver->aof_buf)+aofRewriteBufferSize();
367 }
368 return overhead;
369}
370
371/* Get the memory status from the point of view of the maxmemory directive:
372 * if the memory used is under the maxmemory setting then C_OK is returned.

Callers 4

getMaxmemoryStateFunction · 0.85
overMaxmemoryAfterAllocFunction · 0.85
genRedisInfoStringFunction · 0.85
updateMaxmemoryFunction · 0.85

Calls 7

GlobalLocksAcquiredFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
sdsallocFunction · 0.85
aofRewriteBufferSizeFunction · 0.85

Tested by

no test coverage detected