forked from TrueCloudLab/frostfs-node
[#421] Try using badger for the write-cache
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
65c72f3e0b
commit
1a0cb0f34a
56 changed files with 2234 additions and 747 deletions
|
@ -0,0 +1,52 @@
|
|||
package benchmark
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/writecachebadger"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/writecachebbolt"
|
||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
)
|
||||
|
||||
func BenchmarkWritecache(b *testing.B) {
|
||||
b.Run("bbolt", func(b *testing.B) {
|
||||
cache := writecachebbolt.New(
|
||||
writecachebbolt.WithPath(b.TempDir()),
|
||||
)
|
||||
benchmarkPut(b, cache)
|
||||
})
|
||||
b.Run("badger", func(b *testing.B) {
|
||||
cache := writecachebadger.New(
|
||||
writecachebadger.WithPath(b.TempDir()),
|
||||
)
|
||||
benchmarkPut(b, cache)
|
||||
})
|
||||
}
|
||||
|
||||
func benchmarkPut(b *testing.B, cache writecache.Cache) {
|
||||
if err := cache.Open(false); err != nil {
|
||||
b.Fatalf("initializing: %v", err)
|
||||
}
|
||||
if err := cache.Init(); err != nil {
|
||||
b.Fatalf("opening: %v", err)
|
||||
}
|
||||
defer cache.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
objGen := testutil.RandObjGenerator{ObjSize: 8 << 10}
|
||||
|
||||
b.ResetTimer()
|
||||
for n := 0; n < b.N; n++ {
|
||||
prm := common.PutPrm{
|
||||
Address: oidtest.Address(),
|
||||
Object: objGen.Next(),
|
||||
}
|
||||
if _, err := cache.Put(ctx, prm); err != nil {
|
||||
b.Fatalf("putting: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue