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                 100          53517515 ns/op         4609697 B/op        109 allocs/op
BenchmarkBlobovniczas_Put/tree=10x0-8                100          53417156 ns/op         5213543 B/op        119 allocs/op
BenchmarkBlobovniczas_Put/tree=2x2-8                 100          52124287 ns/op         5117641 B/op        158 allocs/op
BenchmarkBlobovniczas_Put/tree=4x4-8                 100          37065895 ns/op         2129467 B/op        188 allocs/op

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Jul 25, 2023
1 parent 7b86fa2 commit 2080185
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 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,67 @@ 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 = 1 << 20
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),
}

b.ReportAllocs()
b.ResetTimer()

var err error

for i := 0; i < b.N; i++ {
b.StopTimer()
prm.Address = oidtest.Address()
rand.Read(prm.RawData)
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 2080185

Please sign in to comment.