[#1524] metabase: Add some bolt parameters to the configuration

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
experimental
Evgenii Stratonikov 2022-06-15 09:59:51 +03:00 committed by LeL
parent d6043abc24
commit 07e06249d5
8 changed files with 35 additions and 13 deletions

View File

@ -445,6 +445,8 @@ func initShardOptions(c *cfg) {
meta.WithLogger(c.log),
meta.WithPath(metaPath),
meta.WithPermissions(metaPerm),
meta.WithMaxBatchSize(metabaseCfg.BoltDB().MaxBatchSize()),
meta.WithMaxBatchDelay(metabaseCfg.BoltDB().MaxBatchDelay()),
meta.WithBoltDBOptions(&bbolt.Options{
Timeout: 100 * time.Millisecond,
}),

View File

@ -68,6 +68,8 @@ func TestEngineSection(t *testing.T) {
require.Equal(t, "tmp/0/meta", meta.Path())
require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm())
require.Equal(t, 100, meta.BoltDB().MaxBatchSize())
require.Equal(t, 10*time.Millisecond, meta.BoltDB().MaxBatchDelay())
require.Equal(t, "tmp/0/blob", blob.Path())
require.EqualValues(t, 0644, blob.Perm())
@ -98,6 +100,8 @@ func TestEngineSection(t *testing.T) {
require.Equal(t, "tmp/1/meta", meta.Path())
require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm())
require.Equal(t, 200, meta.BoltDB().MaxBatchSize())
require.Equal(t, 20*time.Millisecond, meta.BoltDB().MaxBatchDelay())
require.Equal(t, "tmp/1/blob", blob.Path())
require.EqualValues(t, 0644, blob.Perm())

View File

@ -91,6 +91,8 @@ NEOFS_STORAGE_SHARD_0_WRITECACHE_CAPACITY=3221225472
### Metabase config
NEOFS_STORAGE_SHARD_0_METABASE_PATH=tmp/0/meta
NEOFS_STORAGE_SHARD_0_METABASE_PERM=0644
NEOFS_STORAGE_SHARD_0_METABASE_MAX_BATCH_SIZE=100
NEOFS_STORAGE_SHARD_0_METABASE_MAX_BATCH_DELAY=10ms
### Blobstor config
NEOFS_STORAGE_SHARD_0_BLOBSTOR_PATH=tmp/0/blob
NEOFS_STORAGE_SHARD_0_BLOBSTOR_PERM=0644
@ -125,6 +127,8 @@ NEOFS_STORAGE_SHARD_1_WRITECACHE_CAPACITY=4294967296
### Metabase config
NEOFS_STORAGE_SHARD_1_METABASE_PATH=tmp/1/meta
NEOFS_STORAGE_SHARD_1_METABASE_PERM=0644
NEOFS_STORAGE_SHARD_1_METABASE_MAX_BATCH_SIZE=200
NEOFS_STORAGE_SHARD_1_METABASE_MAX_BATCH_DELAY=20ms
### Blobstor config
NEOFS_STORAGE_SHARD_1_BLOBSTOR_PATH=tmp/1/blob
NEOFS_STORAGE_SHARD_1_BLOBSTOR_PERM=0644

View File

@ -136,7 +136,9 @@
},
"metabase": {
"path": "tmp/0/meta",
"perm": "0644"
"perm": "0644",
"max_batch_size": 100,
"max_batch_delay": "10ms"
},
"blobstor": {
"path": "tmp/0/blob",
@ -173,7 +175,9 @@
},
"metabase": {
"path": "tmp/1/meta",
"perm": "0644"
"perm": "0644",
"max_batch_size": 200,
"max_batch_delay": "20ms"
},
"blobstor": {
"path": "tmp/1/blob",

View File

@ -116,6 +116,8 @@ storage:
metabase:
perm: 0644 # permissions for metabase files(directories: +x for current user and group)
max_batch_size: 200
max_batch_delay: 20ms
blobstor:
compress: false # turn on/off zstd(level 3) compression of stored objects
@ -145,6 +147,8 @@ storage:
metabase:
path: tmp/0/meta # metabase path
max_batch_size: 100
max_batch_delay: 10ms
blobstor:
path: tmp/0/blob # blobstor path

View File

@ -278,20 +278,24 @@ func WithPermissions(perm fs.FileMode) Option {
}
}
// WithBatchSize returns option to specify maximum concurrent operations
// WithMaxBatchSize returns option to specify maximum concurrent operations
// to be processed in a single transactions.
// This option is missing from `bbolt.Options` but is set right after DB is open.
func WithBatchSize(s int) Option {
func WithMaxBatchSize(s int) Option {
return func(c *cfg) {
c.boltBatchSize = s
if s != 0 {
c.boltBatchSize = s
}
}
}
// WithBatchDelay returns option to specify maximum time to wait before
// WithMaxBatchDelay returns option to specify maximum time to wait before
// the batch of concurrent transactions is processed.
// This option is missing from `bbolt.Options` but is set right after DB is open.
func WithBatchDelay(d time.Duration) Option {
func WithMaxBatchDelay(d time.Duration) Option {
return func(c *cfg) {
c.boltBatchDelay = d
if d != 0 {
c.boltBatchDelay = d
}
}
}

View File

@ -29,7 +29,7 @@ func BenchmarkListWithCursor(b *testing.B) {
}
func listWithCursorPrepareDB(b *testing.B) *meta.DB {
db := newDB(b, meta.WithBatchSize(1), meta.WithBoltDBOptions(&bbolt.Options{
db := newDB(b, meta.WithMaxBatchSize(1), meta.WithBoltDBOptions(&bbolt.Options{
NoSync: true,
})) // faster single-thread generation

View File

@ -43,8 +43,8 @@ func prepareObjects(t testing.TB, n int) []*objectSDK.Object {
func BenchmarkPut(b *testing.B) {
b.Run("parallel", func(b *testing.B) {
db := newDB(b,
meta.WithBatchDelay(time.Millisecond*10),
meta.WithBatchSize(runtime.NumCPU()))
meta.WithMaxBatchDelay(time.Millisecond*10),
meta.WithMaxBatchSize(runtime.NumCPU()))
// Ensure the benchmark is bound by CPU and not waiting batch-delay time.
b.SetParallelism(1)
@ -62,8 +62,8 @@ func BenchmarkPut(b *testing.B) {
})
b.Run("sequential", func(b *testing.B) {
db := newDB(b,
meta.WithBatchDelay(time.Millisecond*10),
meta.WithBatchSize(1))
meta.WithMaxBatchDelay(time.Millisecond*10),
meta.WithMaxBatchSize(1))
index := atomic.NewInt64(-1)
objs := prepareObjects(b, b.N)
b.ResetTimer()