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. */
| 1576 | * The function returns 1 if some rehashing was performed, otherwise 0 |
| 1577 | * is returned. */ |
| 1578 | int 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 |
no test coverage detected