From c4865783fc272f4219c075a14b897ffc2845b59d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 11 Apr 2023 20:51:58 +0300 Subject: [PATCH] [#236] blobstor/test: Prefill storage in parallel in read benchmark `blobovniczatree` takes a really long time to prefill, because each batch takes at least 10ms, so for 10k iterations we have at least 100s of prefill. Signed-off-by: Evgenii Stratonikov --- .../blobstor/perf_test.go | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/local_object_storage/blobstor/perf_test.go b/pkg/local_object_storage/blobstor/perf_test.go index a593e1bf4..0351eb56e 100644 --- a/pkg/local_object_storage/blobstor/perf_test.go +++ b/pkg/local_object_storage/blobstor/perf_test.go @@ -11,6 +11,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/memstore" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil" "github.com/stretchr/testify/require" + "golang.org/x/sync/errgroup" ) type storage struct { @@ -103,18 +104,23 @@ func BenchmarkSubstorageReadPerf(b *testing.B) { st := stEntry.open(b) // Fill database + var errG errgroup.Group for i := 0; i < tt.size; i++ { obj := objGen.Next() addr := testutil.AddressFromObject(b, obj) - raw, err := obj.Marshal() - require.NoError(b, err) - if _, err := st.Put(common.PutPrm{ - Address: addr, - RawData: raw, - }); err != nil { - b.Fatalf("writing entry: %v", err) - } + errG.Go(func() error { + raw, err := obj.Marshal() + if err != nil { + return fmt.Errorf("marshal: %v", err) + } + _, err = st.Put(common.PutPrm{ + Address: addr, + RawData: raw, + }) + return err + }) } + require.NoError(b, errG.Wait()) // Benchmark reading addrGen := tt.addrGen()