INFO report peak memory before eviction (#7894)
In some cases one command added a very big bulk of memory, and this would be "resolved" by the eviction before the next command. Seeing an unexplained mass eviction we would wish to know the highest momentary usage too. Tracking it in call() and beforeSleep() adds some hooks in AOF and RDB loading. The fix in clientsCronTrackExpansiveClients is related to #7874 (cherry picked from commit 0de424cab96633a3fc94bcdaec83176eacb080b2)
This commit is contained in:
parent
c9dcf82020
commit
c55bc96dc6
12
src/server.c
12
src/server.c
@ -1573,7 +1573,7 @@ size_t ClientsPeakMemInput[CLIENTS_PEAK_MEM_USAGE_SLOTS];
|
|||||||
size_t ClientsPeakMemOutput[CLIENTS_PEAK_MEM_USAGE_SLOTS];
|
size_t ClientsPeakMemOutput[CLIENTS_PEAK_MEM_USAGE_SLOTS];
|
||||||
|
|
||||||
int clientsCronTrackExpansiveClients(client *c) {
|
int clientsCronTrackExpansiveClients(client *c) {
|
||||||
size_t in_usage = sdsAllocSize(c->querybuf);
|
size_t in_usage = sdsZmallocSize(c->querybuf) + c->argv_len_sum;
|
||||||
size_t out_usage = getClientOutputBufferMemoryUsage(c);
|
size_t out_usage = getClientOutputBufferMemoryUsage(c);
|
||||||
int i = server.unixtime % CLIENTS_PEAK_MEM_USAGE_SLOTS;
|
int i = server.unixtime % CLIENTS_PEAK_MEM_USAGE_SLOTS;
|
||||||
int zeroidx = (i+1) % CLIENTS_PEAK_MEM_USAGE_SLOTS;
|
int zeroidx = (i+1) % CLIENTS_PEAK_MEM_USAGE_SLOTS;
|
||||||
@ -2110,6 +2110,10 @@ extern int ProcessingEventsWhileBlocked;
|
|||||||
void beforeSleep(struct aeEventLoop *eventLoop) {
|
void beforeSleep(struct aeEventLoop *eventLoop) {
|
||||||
UNUSED(eventLoop);
|
UNUSED(eventLoop);
|
||||||
|
|
||||||
|
size_t zmalloc_used = zmalloc_used_memory();
|
||||||
|
if (zmalloc_used > server.stat_peak_memory)
|
||||||
|
server.stat_peak_memory = zmalloc_used;
|
||||||
|
|
||||||
/* Just call a subset of vital functions in case we are re-entering
|
/* Just call a subset of vital functions in case we are re-entering
|
||||||
* the event loop from processEventsWhileBlocked(). Note that in this
|
* the event loop from processEventsWhileBlocked(). Note that in this
|
||||||
* case we keep track of the number of events we are processing, since
|
* case we keep track of the number of events we are processing, since
|
||||||
@ -3485,6 +3489,12 @@ void call(client *c, int flags) {
|
|||||||
|
|
||||||
server.fixed_time_expire--;
|
server.fixed_time_expire--;
|
||||||
server.stat_numcommands++;
|
server.stat_numcommands++;
|
||||||
|
|
||||||
|
/* Record peak memory after each command and before the eviction that runs
|
||||||
|
* before the next command. */
|
||||||
|
size_t zmalloc_used = zmalloc_used_memory();
|
||||||
|
if (zmalloc_used > server.stat_peak_memory)
|
||||||
|
server.stat_peak_memory = zmalloc_used;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used when a command that is ready for execution needs to be rejected, due to
|
/* Used when a command that is ready for execution needs to be rejected, due to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user