[#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 <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-04-11 20:51:58 +03:00
parent 6ad5c38225
commit c4865783fc

View file

@ -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)
errG.Go(func() error {
raw, err := obj.Marshal()
require.NoError(b, err)
if _, err := st.Put(common.PutPrm{
if err != nil {
return fmt.Errorf("marshal: %v", err)
}
_, err = st.Put(common.PutPrm{
Address: addr,
RawData: raw,
}); err != nil {
b.Fatalf("writing entry: %v", err)
}
})
return err
})
}
require.NoError(b, errG.Wait())
// Benchmark reading
addrGen := tt.addrGen()