MCPcopy Create free account
hub / github.com/F-Stack/f-stack / incrementallyRehash

Function incrementallyRehash

app/redis-6.2.6/src/server.c:1578–1590  ·  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 1 if some rehashing was performed, otherwise 0 * is returned. */

Source from the content-addressed store, hash-verified

1576 * The function returns 1 if some rehashing was performed, otherwise 0
1577 * is returned. */
1578int incrementallyRehash(int dbid) {
1579 /* Keys dictionary */
1580 if (dictIsRehashing(server.db[dbid].dict)) {
1581 dictRehashMilliseconds(server.db[dbid].dict,1);
1582 return 1; /* already used our millisecond for this loop... */
1583 }
1584 /* Expires */
1585 if (dictIsRehashing(server.db[dbid].expires)) {
1586 dictRehashMilliseconds(server.db[dbid].expires,1);
1587 return 1; /* already used our millisecond for this loop... */
1588 }
1589 return 0;
1590}
1591
1592/* This function is called once a background process of some kind terminates,
1593 * as we want to avoid resizing the hash tables when there is a child in order

Callers 1

databasesCronFunction · 0.85

Calls 1

dictRehashMillisecondsFunction · 0.85

Tested by

no test coverage detected