Closed RyouZhang closed 1 month ago
You're calling Set()
with a cost of 16, but actually storing more than double that, because you are converting UUID from raw bytes to a string ?:
fmt.Println("len = ", len(uuid.NewString()))
len = 36
You're calling
Set()
with a cost of 16, but actually storing more than double that, because you are converting UUID from raw bytes to a string ?:fmt.Println("len = ", len(uuid.NewString()))
len = 36
the UUID is key, the real value is 16K, and I don't is the reason, because memory cost 2x
@RyouZhang sorry, my mistake. Have you tried going much bigger, like, at 1GB of byte values, does it use 2GB of memory or just 1.1GB?
@RyouZhang sorry, my mistake. Have you tried going much bigger, like, at 1GB of byte values, does it use 2GB of memory or just 1.1GB?
yes, in my prod env, we set 3GB but real used 6+GB
After some reseach, I think the behaivor of ristretto is "correct". The in-use heap size is indeed ~100MB. I think the reason why the RES memory in top is higher is that the gc'ed memory is not returned to the OS. If we add debug.FreeOSMemory()
in the cost printing loop (with a higher frequency, e.g. 1000ms -> 100ms), we can see a lower RES size.
This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.
What version of Ristretto are you using?
0.11
What version of Go are you using?
go 1.19.3
Have you tried reproducing the issue with the latest release?
Yes
What is the hardware spec (RAM, CPU, OS)?
4c/8g Linux 5.4.219-126.411.amzn2.x86_64 #1
What steps will reproduce the bug?
package main
import ( "time" "fmt"
)
func main() {
}
Expected behavior and actual result.
in my demo, the max-cost is 100MB, but top your pid, you will find it's used 200MB memory
Additional information
No response