Skip to content

Commit

Permalink
blobovnicza: Add benchmark to test different tree settings
Browse files Browse the repository at this point in the history
goos: linux
goarch: amd64
pkg: github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/blobovniczatree
cpu: Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
BenchmarkBlobovniczas_Put/tree=1x0-8                  61          19747177 ns/op           33398 B/op         77 allocs/op
BenchmarkBlobovniczas_Put/tree=10x0-8                 60          18623677 ns/op           33600 B/op         77 allocs/op
BenchmarkBlobovniczas_Put/tree=2x2-8                  56          20861449 ns/op           36191 B/op        112 allocs/op
BenchmarkBlobovniczas_Put/tree=4x4-8                  43          25999988 ns/op           38511 B/op        182 allocs/op

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Jul 25, 2023
1 parent 7b86fa2 commit cc3fb47
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions pkg/local_object_storage/blobstor/blobovniczatree/put_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package blobovniczatree_test

import (
"crypto/rand"
"errors"
"fmt"
"testing"

. "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/blobovniczatree"
Expand Down Expand Up @@ -37,3 +40,68 @@ func TestSingleDir(t *testing.T) {
})
require.NoError(t, err)
}

func benchmarkPutMN(b *testing.B, depth, width uint64) {
nBlobovniczas := uint64(1)
for i := uint64(1); i <= depth+1; i++ {
nBlobovniczas *= width
}

const objSizeLimit = 4 << 10
const fullSizeLimit = 100 << 20

bbcz := NewBlobovniczaTree(
WithRootPath(b.TempDir()),
WithObjectSizeLimit(objSizeLimit),
WithBlobovniczaSize(fullSizeLimit/nBlobovniczas),
WithBlobovniczaShallowWidth(width),
WithBlobovniczaShallowDepth(depth),
)

require.NoError(b, bbcz.Open(false))
b.Cleanup(func() { _ = bbcz.Close() })
require.NoError(b, bbcz.Init())

prm := common.PutPrm{
RawData: make([]byte, objSizeLimit),
}

rand.Read(prm.RawData)

b.ReportAllocs()
b.ResetTimer()

var err error

for i := 0; i < b.N; i++ {
b.StopTimer()
prm.Address = oidtest.Address()
b.StartTimer()

_, err = bbcz.Put(prm)

b.StopTimer()
if err != nil {
if errors.Is(err, common.ErrNoSpace) {
break
}
require.NoError(b, err)
}
b.StartTimer()
}
}

func BenchmarkBlobovniczas_Put(b *testing.B) {
for _, testCase := range []struct {
width, depth uint64
}{
{1, 0},
{10, 0},
{2, 2},
{4, 4},
} {
b.Run(fmt.Sprintf("tree=%dx%d", testCase.width, testCase.depth), func(b *testing.B) {
benchmarkPutMN(b, testCase.depth, testCase.width)
})
}
}

0 comments on commit cc3fb47

Please sign in to comment.