forked from TrueCloudLab/frostfs-node
[#1450] engine: Add benchmark Inhume
when there's many addresses
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
a8b18317c1
commit
87e909343f
1 changed files with 52 additions and 0 deletions
|
@ -2,6 +2,7 @@ package engine
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
|
@ -9,7 +10,11 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
objecttest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func TestStorageEngine_Inhume(t *testing.T) {
|
||||
|
@ -83,3 +88,50 @@ func TestStorageEngine_Inhume(t *testing.T) {
|
|||
require.Empty(t, addrs)
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkInhumeMultipart(b *testing.B) {
|
||||
for objects := 1; objects <= 10000; objects *= 10 {
|
||||
b.Run(fmt.Sprintf("%d_parts", objects), func(b *testing.B) {
|
||||
benchmarkInhumeMultipart(b, 100, objects)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func benchmarkInhumeMultipart(b *testing.B, S, N int) {
|
||||
b.StopTimer()
|
||||
|
||||
for range b.N {
|
||||
engine := testNewEngine(b, WithShardPoolSize(uint32(N))).setShardsNum(b, S).engine
|
||||
|
||||
cnr := cidtest.ID()
|
||||
var addrs []oid.Address
|
||||
|
||||
eg := errgroup.Group{}
|
||||
for range N {
|
||||
prm := PutPrm{}
|
||||
|
||||
prm.Object = objecttest.Object().Parent()
|
||||
prm.Object.SetContainerID(cnr)
|
||||
prm.Object.SetType(objectSDK.TypeRegular)
|
||||
addrs = append(addrs, object.AddressOf(prm.Object))
|
||||
|
||||
eg.Go(func() error {
|
||||
return engine.Put(context.Background(), prm)
|
||||
})
|
||||
}
|
||||
require.NoError(b, eg.Wait())
|
||||
|
||||
ts := oidtest.Address()
|
||||
ts.SetContainer(cnr)
|
||||
|
||||
prm := InhumePrm{}
|
||||
prm.WithTarget(ts, addrs...)
|
||||
|
||||
b.StartTimer()
|
||||
_, err := engine.Inhume(context.Background(), prm)
|
||||
require.NoError(b, err)
|
||||
b.StopTimer()
|
||||
|
||||
require.NoError(b, engine.Close(context.Background()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue