dgraph-io / ristretto

A high performance memory-bound Go cache
https://dgraph.io/blog/post/introducing-ristretto-high-perf-go-cache/
Apache License 2.0
5.54k stars 364 forks source link

[SERIOUS BUG]: negative key cache hit problem #369

Closed UallenQbit closed 7 months ago

UallenQbit commented 8 months ago

What version of Ristretto are you using?

github.com/dgraph-io/ristretto v0.1.1

What version of Go are you using?

go version go1.21.5 windows/amd64

Have you tried reproducing the issue with the latest release?

None

What is the hardware spec (RAM, CPU, OS)?

Intel Core i9 12900HX | 64.0GB | Windows 11

What steps will reproduce the bug?

z/z.go func KeyToHash image_2024-01-09_15-24-55 if int int32 int64 is negative, the result will be 18446744073709551516 when converting uint64 this will cause everything to hit one shards, which will cause the performance of negative keys to seriously degrade!

Yonghui-Lee commented 7 months ago

@UallenQbit When converting a negative integer into uint64, the result won't always be 18446744073709551516. Actually, the result will be the complemnt code of it. So different negative keys won't hit the same shard.

UallenQbit commented 7 months ago

@UallenQbit When converting a negative integer into uint64, the result won't always be 18446744073709551516. Actually, the result will be the complemnt code of it. So different negative keys won't hit the same shard.

Where is the other code for this?

Yonghui-Lee commented 7 months ago

I mean the result will be two's complement of the negative number.