mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
ristretto: adjust NumCounters
This commit is contained in:
parent
3002f867fa
commit
941fa38123
1 changed files with 5 additions and 2 deletions
|
|
@ -32,9 +32,12 @@ type RistrettoCache struct {
|
|||
// NewRistrettoCache create a new ristretto cache with the given
|
||||
// capacity in MB
|
||||
func NewRistrettoCache(capacity int) (*RistrettoCache, error) {
|
||||
maxBytes := int64(1000 * 1000 * capacity)
|
||||
// Let's assume an item is around 500 bytes large
|
||||
approxItems := maxBytes / 500
|
||||
cache, err := ristretto.NewCache(&ristretto.Config{
|
||||
NumCounters: int64(capacity * 10),
|
||||
MaxCost: int64(1000 * 1000 * capacity),
|
||||
NumCounters: int64(approxItems * 10),
|
||||
MaxCost: maxBytes,
|
||||
BufferItems: 64,
|
||||
Metrics: false,
|
||||
KeyToHash: func(key interface{}) uint64 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue