Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION]: Too high missed rate? #346

Open
maxim-ge opened this issue Aug 15, 2023 · 0 comments
Open

[QUESTION]: Too high missed rate? #346

maxim-ge opened this issue Aug 15, 2023 · 0 comments
Labels
kind/question Something requiring a response.

Comments

@maxim-ge
Copy link

Question.

I have a test:

func TestRistretto_Get(t *testing.T) {
	require := require.New(t)

	const CacheSize = 10_000

	m, err := ristretto.NewCache(&ristretto.Config{
		NumCounters: CacheSize / 10, // number of keys to track frequency
		MaxCost:     CacheSize,      // maximum cost of cache
		BufferItems: 64,             // number of keys per Get buffer.
	})
	require.NoError(err)

	numFound := 0
	numMissed := 0

	for i := 0; i < CacheSize; i++ {
		k := fmt.Sprint(i)
		for {
			r := m.Set(k, i+1, 1)
			m.Wait()
			if r {
				break
			}
		}
		_, ok := m.Get(k)
		if !ok {
			numMissed++
		} else {
			numFound++
		}
	}
	fmt.Println("numOk:", numFound, "numMissed:", numMissed)
	require.NotNil(t)
}

It prints numOk: 3494 numMissed: 6506. Is it ok that so many keys are missed?

@maxim-ge maxim-ge added the kind/question Something requiring a response. label Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Something requiring a response.
Projects
None yet
Development

No branches or pull requests

1 participant