Skip to content

Commit a9c3627

Browse files
committed
notifs: add micro-benchmarks for subsequent comparison
Signed-off-by: Alex Aizman <[email protected]>
1 parent d516616 commit a9c3627

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

ais/prxnotif_internal_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"bytes"
99
"net/http"
1010
"net/http/httptest"
11+
"testing"
1112
"time"
1213

1314
"github.com/NVIDIA/aistore/api/apc"
@@ -291,3 +292,75 @@ var _ = Describe("Notifications xaction test", func() {
291292
})
292293
})
293294
})
295+
296+
func BenchmarkShardedAdd(b *testing.B) {
297+
cos.InitShortID(0)
298+
n := &notifs{
299+
nls: newListeners(),
300+
fin: newListeners(),
301+
}
302+
smap := &smapX{}
303+
targets := make(meta.NodeMap, 1)
304+
targets["target1"] = &meta.Snode{DaeID: "target1"}
305+
306+
b.ResetTimer()
307+
for range b.N {
308+
xid := cos.GenUUID()
309+
nl := xact.NewXactNL(xid, apc.ActECEncode, &smap.Smap, targets)
310+
n.nls.add(nl, false)
311+
}
312+
}
313+
314+
func BenchmarkShardedEntry(b *testing.B) {
315+
cos.InitShortID(0)
316+
n := &notifs{
317+
nls: newListeners(),
318+
fin: newListeners(),
319+
}
320+
smap := &smapX{}
321+
targets := make(meta.NodeMap, 1)
322+
targets["target1"] = &meta.Snode{DaeID: "target1"}
323+
324+
// Seed with listeners
325+
xids := make([]string, 1000)
326+
for i := range xids {
327+
xid := cos.GenUUID()
328+
xids[i] = xid
329+
nl := xact.NewXactNL(xid, apc.ActECEncode, &smap.Smap, targets)
330+
n.nls.add(nl, false)
331+
}
332+
333+
b.ResetTimer()
334+
for i := range b.N {
335+
xid := xids[i%len(xids)]
336+
_, _ = n.nls.entry(xid)
337+
}
338+
}
339+
340+
func BenchmarkShardedConcurrentMixed(b *testing.B) {
341+
cos.InitShortID(0)
342+
n := &notifs{
343+
nls: newListeners(),
344+
fin: newListeners(),
345+
}
346+
smap := &smapX{}
347+
targets := make(meta.NodeMap, 1)
348+
targets["target1"] = &meta.Snode{DaeID: "target1"}
349+
350+
b.ResetTimer()
351+
b.RunParallel(func(pb *testing.PB) {
352+
for pb.Next() {
353+
xid := cos.GenUUID()
354+
nl := xact.NewXactNL(xid, apc.ActECEncode, &smap.Smap, targets)
355+
356+
// Add
357+
n.nls.add(nl, false)
358+
359+
// Lookup
360+
_, _ = n.nls.entry(xid)
361+
362+
// Delete
363+
n.nls.del(nl, false)
364+
}
365+
})
366+
}

0 commit comments

Comments
 (0)