Iterating all the clients in getMemoryOverheadData() is too slow and * in turn would make the INFO command too slow. So we perform this * computation incrementally and track the (not instantaneous but updated * to the second) total memory used by clients using clinetsCron() in * a more incremental way (depending on server.hz). */
| 1752 | * to the second) total memory used by clients using clinetsCron() in |
| 1753 | * a more incremental way (depending on server.hz). */ |
| 1754 | int clientsCronTrackClientsMemUsage(client *c) { |
| 1755 | size_t mem = 0; |
| 1756 | int type = getClientType(c); |
| 1757 | mem += getClientOutputBufferMemoryUsage(c); |
| 1758 | mem += sdsZmallocSize(c->querybuf); |
| 1759 | mem += zmalloc_size(c); |
| 1760 | mem += c->argv_len_sum; |
| 1761 | if (c->argv) mem += zmalloc_size(c->argv); |
| 1762 | /* Now that we have the memory used by the client, remove the old |
| 1763 | * value from the old category, and add it back. */ |
| 1764 | server.stat_clients_type_memory[c->client_cron_last_memory_type] -= |
| 1765 | c->client_cron_last_memory_usage; |
| 1766 | server.stat_clients_type_memory[type] += mem; |
| 1767 | /* Remember what we added and where, to remove it next time. */ |
| 1768 | c->client_cron_last_memory_usage = mem; |
| 1769 | c->client_cron_last_memory_type = type; |
| 1770 | return 0; |
| 1771 | } |
| 1772 | |
| 1773 | /* Return the max samples in the memory usage of clients tracked by |
| 1774 | * the function clientsCronTrackExpansiveClients(). */ |
no test coverage detected