mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
clientsCronTrackExpansiveClients() actual implementation.
This commit is contained in:
parent
d4c5fc57db
commit
85a1b4f807
15
src/server.c
15
src/server.c
@ -897,13 +897,26 @@ int clientsCronResizeQueryBuffer(client *c) {
|
||||
*
|
||||
* When we want to know what was recently the peak memory usage, we just scan
|
||||
* such few slots searching for the maximum value. */
|
||||
#define CLIENTS_PEAK_MEM_USAGE_SLOTS 10
|
||||
#define CLIENTS_PEAK_MEM_USAGE_SLOTS 8
|
||||
size_t ClientsPeakMemInput[CLIENTS_PEAK_MEM_USAGE_SLOTS];
|
||||
size_t ClientsPeakMemOutput[CLIENTS_PEAK_MEM_USAGE_SLOTS];
|
||||
|
||||
int clientsCronTrackExpansiveClients(client *c) {
|
||||
size_t in_usage = sdsAllocSize(c->querybuf);
|
||||
size_t out_usage = getClientOutputBufferMemoryUsage(c);
|
||||
int i = server.unixtime % CLIENTS_PEAK_MEM_USAGE_SLOTS;
|
||||
int j = (i+1) % CLIENTS_PEAK_MEM_USAGE_SLOTS;
|
||||
|
||||
/* Always zero the next sample, so that when we switch to that second, we'll
|
||||
* only register samples that are greater in that second without considering
|
||||
* the history of such slot. */
|
||||
ClientsPeakMemInput[j] = 0;
|
||||
ClientsPeakMemOutput[j] = 0;
|
||||
|
||||
/* Track the biggest values observed so far in this slot. */
|
||||
if (in_usage > ClientsPeakMemInput[i]) ClientsPeakMemInput[i] = in_usage;
|
||||
if (out_usage > ClientsPeakMemOutput[i]) ClientsPeakMemOutput[i] = out_usage;
|
||||
|
||||
return 0; /* This function never terminates the client. */
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user