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

LFU Delete/pop key take a long time #55

Closed
RelicOfTesla opened this issue Apr 15, 2024 · 5 comments · Fixed by #56
Closed

LFU Delete/pop key take a long time #55

RelicOfTesla opened this issue Apr 15, 2024 · 5 comments · Fixed by #56

Comments

@RelicOfTesla
Copy link

RelicOfTesla commented Apr 15, 2024

func TestLFUPop(t *testing.T) {
	const maxKeySize = 10000000
	c := New[int, int](AsLFU[int, int](lfu.WithCapacity(maxKeySize)))
	take := time.Now()
	for i := 0; i < maxKeySize; i++ {
		c.Set(i, i)
	}
	t.Log(time.Since(take))

	take = time.Now()
	for i := 0; i < 300; i++ {
		c.Delete(i * 2)
	}
	t.Log(time.Since(take))
}
=== RUN   TestLFUPop
    cache_internal_test.go:366: 7.5215588s
    cache_internal_test.go:372: 11.4654817s   // delete 300 count key...used 11sec
@Code-Hex
Copy link
Owner

Code-Hex commented Apr 15, 2024

@RelicOfTesla Thanks for your creating issue!

Please write descriptions what do you think problem? What do you have expectation? What can I do for that?

If you have additional context, please write more description. Thanks!

@Code-Hex
Copy link
Owner

profile
profile.pb.gz

@RelicOfTesla
Copy link
Author

Do you think deleting 300 keys takes more than 10+ seconds is a normal result?

Time-consuming code:

new := old[0 : n-1]
for i := 0; i < len(new); i++ {
new[i].index = i
}
*q = new

@RelicOfTesla RelicOfTesla mentioned this issue Apr 15, 2024
@Code-Hex
Copy link
Owner

@RelicOfTesla I would appreciate it if you could be a little more polite in your issue. i.e. add profile

Code-Hex added a commit that referenced this issue Apr 15, 2024
@Code-Hex Code-Hex mentioned this issue Apr 15, 2024
Code-Hex added a commit that referenced this issue Apr 15, 2024
@RelicOfTesla
Copy link
Author

Sorry, my English is not very good. I may have used inappropriate words semantically, which makes you feel uncomfortable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants