dgraph-io / ristretto

A high performance memory-bound Go cache

Home Page:https://dgraph.io/blog/post/introducing-ristretto-high-perf-go-cache/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[SERIOUS BUG]: negative key cache hit problem

UallenQbit opened this issue · comments

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!

@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 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?

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