From 87e909343f1cf56cb6f4670a9b6383e0e979e674 Mon Sep 17 00:00:00 2001 From: Aleksey Savchuk Date: Sat, 2 Nov 2024 12:51:44 +0300 Subject: [PATCH] [#1450] engine: Add benchmark `Inhume` when there's many addresses Signed-off-by: Aleksey Savchuk --- .../engine/inhume_test.go | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/pkg/local_object_storage/engine/inhume_test.go b/pkg/local_object_storage/engine/inhume_test.go index b4fbbd810..59a1affbe 100644 --- a/pkg/local_object_storage/engine/inhume_test.go +++ b/pkg/local_object_storage/engine/inhume_test.go @@ -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())) + } +}