performEvictions: mem_freed may be negative#7908
Conversation
|
@guybe7 can you describe how it can become negative (should at least be stated for the record)? |
|
@oranagra i can't think of any other cases |
src/evict.c
Outdated
There was a problem hiding this comment.
do we want to consider a case where on 32bit system, redis is eating more than 2GB of ram, and decided it needs to free most of it (i.e mem_tofree > 2gb)?
in which case, maybe mem_freed needs to be long long? or not count negative deltas?
There was a problem hiding this comment.
maybe the right thing to do is to change it to long long instead of ssize_t
should i do it?
There was a problem hiding this comment.
hold on..
if there's a small sporadic negative delta, that's not that bad.. pretty soon other positive deltas will overcome it and mem_freed will become positive again, right?
so it's only a problem if it consistently gets negative deltas, right?
but another look at the code it actually seems that the initial report is wrong.
in case of negative delta it'll just exit immediately (not keep running the loop for a lot more than it should). making my claim above (about positive deltas eventually overcoming the rare negative delta) wrong.
is that right? if it is, then yes. let's make it long long and update the comment.
There was a problem hiding this comment.
it seems you're right... we're not talking about over-eviction we're talking about reaching OOM
i'll change to long long and update the comment
If 'delta' is negative 'mem_freed' may underflow and cause the while loop to exit prematurely (And not evicting enough memory) mem_freed can be negative when: 1. We use lazy free (consuming memory by appending to a list) 2. Thread doing an allocation between the two calls to zmalloc_used_memory.
|
@oranagra done |
If 'delta' is negative 'mem_freed' may underflow and cause the while loop to exit prematurely (And not evicting enough memory) mem_freed can be negative when: 1. We use lazy free (consuming memory by appending to a list) 2. Thread doing an allocation between the two calls to zmalloc_used_memory.
If 'delta' is negative 'mem_freed' may underflow and cause
the while loop to exit prematurely (And not evicting enough
memory)
mem_freed can be negative when: