-
Notifications
You must be signed in to change notification settings - Fork 699
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
BatchLookupAndDelete is much slower than iterator #1078
Comments
Can you add |
diff --git a/map_test.go b/map_test.go
index 6908077..5a95b93 100644
--- a/map_test.go
+++ b/map_test.go
@@ -2007,7 +2007,7 @@ func BenchmarkHashDelete(b *testing.B) {
var k, v uint64
b.ReportAllocs()
-
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
iter := m.Iterate()
for iter.Next(&k, &v) {
@@ -2030,7 +2030,7 @@ func BenchmarkHashDelete(b *testing.B) {
v := make([]uint64, m.MaxEntries())
b.ReportAllocs()
-
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
var next uint32
_, err := m.BatchLookupAndDelete(nil, &next, k, v, nil) BenchmarkHashDelete/MapIteratorDelete-12 405836 3537 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 383348 2704 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 504504 3335 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 346116 2909 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 382950 3025 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 31327 39469 ns/op 32846 B/op 8 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 33157 37318 ns/op 32846 B/op 8 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 27322 38024 ns/op 32846 B/op 8 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 30834 39786 ns/op 32846 B/op 8 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 36780 38381 ns/op 32846 B/op 8 allocs/op
PASS
|
I'm guessing this has to do with the marshaling of the slices. Can you mess around with various orders of magnitudes of the map size, to see if the difference is still just as drastic? |
BenchmarkHashDelete/MapIteratorDelete-12 1309647 908.2 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 1238526 911.7 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 1304388 905.3 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 432500 2518 ns/op 3649 B/op 8 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 389462 2595 ns/op 3649 B/op 8 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 374091 2715 ns/op 3649 B/op 8 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 74716 14481 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 81942 13710 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 81295 14660 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 7556 145436 ns/op 327898 B/op 8 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 8298 142024 ns/op 327899 B/op 8 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 8420 135013 ns/op 327899 B/op 8 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 1 5621548609 ns/op 6403464 B/op 400013 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 10000 105828 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapIteratorDelete-12 10000 103966 ns/op 80 B/op 4 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 885 1356382 ns/op 3212373 B/op 9 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 949 1315810 ns/op 3212377 B/op 9 allocs/op
BenchmarkHashDelete/MapBatchLookupAndDelete-12 742 1456063 ns/op 3212373 B/op 9 allocs/op
|
@msherif1234 Sorry, these benchmarks don't make any sense, except maybe: This demonstrates why: after the first iteration, the hash map is empty and subsequent MapIterators will return
That said, it does seem like |
Describe the bug
It was expected to see much better performance when using BatchLookupAndDelete compared to regular iterate and delete loop
To Reproduce
https://github.com/msherif1234/ebpf/tree/batch_performance
Expected behavior
I was expecting much better cpu and memory when using Batch apis
The text was updated successfully, but these errors were encountered: