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

Method incrementallyRehash

src/server.cpp:1692–1700  ·  view source on GitHub ↗

Our hash table implementation performs rehashing incrementally while * we write/read from the hash table. Still if the server is idle, the hash * table will use two tables for a long time. So we try to use 1 millisecond * of CPU time at every call of this function to perform some rehashing. * * The function returns the number of rehashes if some rehashing was performed, otherwise 0 * is retu

Source from the content-addressed store, hash-verified

1690 * The function returns the number of rehashes if some rehashing was performed, otherwise 0
1691 * is returned. */
1692int redisDbPersistentData::incrementallyRehash() {
1693 /* Keys dictionary */
1694 int result = 0;
1695 if (dictIsRehashing(m_pdict))
1696 result += dictRehashMilliseconds(m_pdict,1);
1697 if (dictIsRehashing(m_pdictTombstone))
1698 dictRehashMilliseconds(m_pdictTombstone,1); // don't count this
1699 return result; /* already used our millisecond for this loop... */
1700}
1701
1702/* This function is called once a background process of some kind terminates,
1703 * as we want to avoid resizing the hash tables when there is a child in order

Callers 1

databasesCronFunction · 0.80

Calls 1

dictRehashMillisecondsFunction · 0.85

Tested by

no test coverage detected