memory reporting of clients argv#7874
memory reporting of clients argv#7874oranagra merged 4 commits intoredis:unstablefrom oranagra:track_client_argv
Conversation
track and report memory used by clients argv. this is very usaful in case clients started sending a command and didn't complete it. in which case the first args of the command are already trimmed from the query buffer. in an effort to avoid cache misses and overheads while keeping track of these, i avoid calling sdsZmallocSize and instead use the sdslen / bulk-len which can at least give some insight into the problem. This memory is now added to the total clients memory usage, as well as the client list.
|
This is a portion of #5159 (applying Salvatore's feedback of using the bulk length or sdslen instead of sdsZmallocSize (not tracking internal fragmentation and unused sds memory, in order to reduce the risk of any overhead on performance) |
|
I can add a test that tests it (sends an incomplete command) if you feel that's useful. |
src/networking.c
Outdated
| /* Compute the total memory consumed by this client. */ | ||
| size_t obufmem = getClientOutputBufferMemoryUsage(client); | ||
| size_t total_mem = obufmem; | ||
| total_mem += sizeof(client); /* includes client->buf */ |
There was a problem hiding this comment.
nit: we could also get actual allocation of client rather than sizeof. Probably totally negligible.
There was a problem hiding this comment.
it might not be negligible, it's likely to have some 30% overhead.
There was a problem hiding this comment.
30% of just sizeof(client) is not that much, but yeah it could be noticeable in some scenarios.
There was a problem hiding this comment.
note that i fixed that in both CLIENT LIST, and the cron that collects data for INFO MEMORY
src/server.h
Outdated
| size_t querybuf_peak; /* Recent (100ms or more) peak of querybuf size. */ | ||
| int argc; /* Num of arguments of current command. */ | ||
| robj **argv; /* Arguments of current command. */ | ||
| size_t argv_sum; /* Sum of lengths of objects in argv list. */ |
There was a problem hiding this comment.
I'd consider a more descriptive name, e.g. argv_mem.
There was a problem hiding this comment.
i wanted to denote that it's the sum of lengths (chars) and not memory (includes internal frag and sds unused space).
maybe you have a better suggestion?
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
track and report memory used by clients argv. this is very usaful in case clients started sending a command and didn't complete it. in which case the first args of the command are already trimmed from the query buffer. in an effort to avoid cache misses and overheads while keeping track of these, i avoid calling sdsZmallocSize and instead use the sdslen / bulk-len which can at least give some insight into the problem. This memory is now added to the total clients memory usage, as well as the client list. (cherry picked from commit bea40e6)
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 457b707)
track and report memory used by clients argv. this is very usaful in case clients started sending a command and didn't complete it. in which case the first args of the command are already trimmed from the query buffer. in an effort to avoid cache misses and overheads while keeping track of these, i avoid calling sdsZmallocSize and instead use the sdslen / bulk-len which can at least give some insight into the problem. This memory is now added to the total clients memory usage, as well as the client list.
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 redis#7874
track and report memory used by clients argv. this is very usaful in case clients started sending a command and didn't complete it. in which case the first args of the command are already trimmed from the query buffer. in an effort to avoid cache misses and overheads while keeping track of these, i avoid calling sdsZmallocSize and instead use the sdslen / bulk-len which can at least give some insight into the problem. This memory is now added to the total clients memory usage, as well as the client list. (cherry picked from commit bea40e6)
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 redis#7874 (cherry picked from commit 457b707)
track and report memory used by clients argv.
this is very usaful in case clients started sending a command and didn't
complete it. in which case the first args of the command are already
trimmed from the query buffer.
in an effort to avoid cache misses and overheads while keeping track of
these, i avoid calling sdsZmallocSize and instead use the sdslen /
bulk-len which can at least give some insight into the problem.
This memory is now added to the total clients memory usage, as well as
the client list.