-
Notifications
You must be signed in to change notification settings - Fork 24.4k
memory reporting of clients argv and scripts #5159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@oranagra I humbly beg that you compare your 2 to mine - https://github.com/antirez/redis/pull/4883 - iterating is slow :) |
|
@itamarhaber thanks, indeed my script counting code would have slowed down INFO in cases were there are many many scripts. |
|
Thank you, other one merged. |
|
Reopening this one as I think there is more meat to merge. |
|
@antirez yes, this PR contained 4 commits, one of which was overlapping another PR (which was better in some aspects), so i removed that commit from this PR (now contains 3 commits). |
|
@antirez a reminder about this one in case you meant to review and forgot. also do you want me to resolve that minor conflict that was created by merging the other PR, or will you handle that in case you merge? |
|
Thanks for bumping this on the list! I'll check tomorrow, a rebase would be appreciated, and sorry for breaking the patch merging other stuff. |
|
P.S. I wish Github could warn users about "merging this will make X,Y,Z impossible to merge". For instance a few days ago I merged a typos PR that ruined a number of other PRs... |
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.
…s internal frag This commit has two aspects: 1) improve memory reporting for all the places that use sdsAllocSize to compute memory used by a string, in this case it'll include the internal fragmentation. 2) reduce the need for realloc calls by making the sds implicitly take over the internal fragmentation of the block it allocated.
|
resolved (push -f). the conflicts were created by another PR i submitted (which i intended you to merge only if you decide not to merge this one). i share the same pain about merge conflicts (mainly when cherry picking between branches).. many times i prefer not to fix types and formatting problems (white space and others), or even not to refactor ugly code (if it's bug free), so that it won't cause conflicts. |
|
Hi @oranagra, I was checking the first commit implementing the argv memory reporting.
The first is introduced by your commit, the second is already in the source tree. In turn the two calls two different functions to return the memory used by an SDS string:
The first returns the SDS logical memory used: header + size of the allocation including the final null term. The second instead reports the size of the allocation where the SDS is stored. I wonder if we need both (probably yes, because sometimes we want to understand the total memory usage and sometimes just what the higher level API tried to allocate), but anyway the naming scheme of such functions look very confusing. So I think here there is a good chance to fix this. I would change them in the following way:
WDYT? |
|
@antirez thanks for reviewing. anyway, this is just naming, so after the above arguments, feel free to decide what sounds best to you, and either rename yourself, or ask me to fix the PR. however, like i did several times in the past, this PR introduces the changes in several stages (so that you can decide to merge just the first commit, or first two, without merging the last). the reason i didn't use sdsZmallocSize in the first commit, and instead introduced a new function that reports the "logical" size without fragmentation, was that i didn't want the performance overhead of calling sdsZmallocSize. but the 3rd commit changes sds.c in a way that every sds is now aware of it's internal fragmentation.
p.s. in the light of the recent #5397, i've reviewed my second commit and i see two things that need fixing:
so anyway, please finish your review and decide what parts you want to merge. |
|
Thank you @oranagra. A few remarks:
I think that this preserves completely the goal of your original commit, that is to understand if some client is doing crazy stuff. However I've the feeling that calling the function and potentially having to cache-miss, may have an impact in certain work loads. Otherwise I'm taking the commit exactly like you proposed it, with the changes needed to apply it (since we accumulated other differences).
|
|
Ok that's the idea about the point "1" above: https://github.com/antirez/redis/compare/argv-accounting |
|
@antirez i'm not 100% sure i follow you, i'll try to respond, but if you feel that i lost you, please help me get back on the track. your 1,2,3 are talking on each of the 3 commits, right?
besides that, IIUC your code from the above mentioned branch, it looks like c->argv_bytes is mixing values from various sources, in which case there may be a creeping leak. i.e. if one place adds sdslen, and the other adds or deducts getStringObjectSdsUsedMemory. we must make sure we always use the same source.
|
|
@antirez you may have missed my response above. |
|
@oranagra thanks, yes checking those as well, started from the bug fixes to release a new RC ASAP. |
|
Closing this old PR, changes and above feedback where ported to the above 3 mentioned PRs |
This PR contains several commits handling related things. please feel free to cherry pick just the first 2 commits, or any other portions you like.
Track and report memory used by clients argv.
this is very useful 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.
report memory used by scripts (not the lua lib itself).please use Adds memory information about the scripts' cache to INFO #4883 insteadthis is useful in case a bad client is flooding the server with many
unique scripts, and their code in redis takes a lot of ram.
Include internal sds fragmentation in MEMORY reporting
performance and memory reporting improvment - sds take control of it's internal frag
this commit has two aspects:
A) improve memory reporting for all the places that use sdsAllocSize to compute
memory used by a string, in this case it'll include the internal fragmentation.
B) reduce the need for realloc calls by making the sds implicitly take over
the internal fragmentation of the block it allocated.