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 g_pserver->hz). */
| 1931 | * to the second) total memory used by clients using clinetsCron() in |
| 1932 | * a more incremental way (depending on g_pserver->hz). */ |
| 1933 | int clientsCronTrackClientsMemUsage(client *c) { |
| 1934 | size_t mem = 0; |
| 1935 | int type = getClientType(c); |
| 1936 | mem += getClientOutputBufferMemoryUsage(c); |
| 1937 | mem += sdsZmallocSize(c->querybuf); |
| 1938 | mem += zmalloc_size(c); |
| 1939 | mem += c->argv_len_sum(); |
| 1940 | if (c->argv) mem += zmalloc_size(c->argv); |
| 1941 | /* Now that we have the memory used by the client, remove the old |
| 1942 | * value from the old category, and add it back. */ |
| 1943 | g_pserver->stat_clients_type_memory[c->client_cron_last_memory_type] -= |
| 1944 | c->client_cron_last_memory_usage; |
| 1945 | g_pserver->stat_clients_type_memory[type] += mem; |
| 1946 | /* Remember what we added and where, to remove it next time. */ |
| 1947 | c->client_cron_last_memory_usage = mem; |
| 1948 | c->client_cron_last_memory_type = type; |
| 1949 | return 0; |
| 1950 | } |
| 1951 | |
| 1952 | /* Return the max samples in the memory usage of clients tracked by |
| 1953 | * the function clientsCronTrackExpansiveClients(). */ |
no test coverage detected