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

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
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.WithLogger(c.log),
meta.WithPath(metaPath), meta.WithPath(metaPath),
meta.WithPermissions(metaPerm), meta.WithPermissions(metaPerm),
meta.WithMaxBatchSize(metabaseCfg.BoltDB().MaxBatchSize()),
meta.WithMaxBatchDelay(metabaseCfg.BoltDB().MaxBatchDelay()),
meta.WithBoltDBOptions(&bbolt.Options{ meta.WithBoltDBOptions(&bbolt.Options{
Timeout: 100 * time.Millisecond, 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, "tmp/0/meta", meta.Path())
require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm()) 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.Equal(t, "tmp/0/blob", blob.Path())
require.EqualValues(t, 0644, blob.Perm()) 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, "tmp/1/meta", meta.Path())
require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm()) 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.Equal(t, "tmp/1/blob", blob.Path())
require.EqualValues(t, 0644, blob.Perm()) require.EqualValues(t, 0644, blob.Perm())

View file

@ -91,6 +91,8 @@ NEOFS_STORAGE_SHARD_0_WRITECACHE_CAPACITY=3221225472
### Metabase config ### Metabase config
NEOFS_STORAGE_SHARD_0_METABASE_PATH=tmp/0/meta NEOFS_STORAGE_SHARD_0_METABASE_PATH=tmp/0/meta
NEOFS_STORAGE_SHARD_0_METABASE_PERM=0644 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 ### Blobstor config
NEOFS_STORAGE_SHARD_0_BLOBSTOR_PATH=tmp/0/blob NEOFS_STORAGE_SHARD_0_BLOBSTOR_PATH=tmp/0/blob
NEOFS_STORAGE_SHARD_0_BLOBSTOR_PERM=0644 NEOFS_STORAGE_SHARD_0_BLOBSTOR_PERM=0644
@ -125,6 +127,8 @@ NEOFS_STORAGE_SHARD_1_WRITECACHE_CAPACITY=4294967296
### Metabase config ### Metabase config
NEOFS_STORAGE_SHARD_1_METABASE_PATH=tmp/1/meta NEOFS_STORAGE_SHARD_1_METABASE_PATH=tmp/1/meta
NEOFS_STORAGE_SHARD_1_METABASE_PERM=0644 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 ### Blobstor config
NEOFS_STORAGE_SHARD_1_BLOBSTOR_PATH=tmp/1/blob NEOFS_STORAGE_SHARD_1_BLOBSTOR_PATH=tmp/1/blob
NEOFS_STORAGE_SHARD_1_BLOBSTOR_PERM=0644 NEOFS_STORAGE_SHARD_1_BLOBSTOR_PERM=0644

View file

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

View file

@ -116,6 +116,8 @@ storage:
metabase: metabase:
perm: 0644 # permissions for metabase files(directories: +x for current user and group) perm: 0644 # permissions for metabase files(directories: +x for current user and group)
max_batch_size: 200
max_batch_delay: 20ms
blobstor: blobstor:
compress: false # turn on/off zstd(level 3) compression of stored objects compress: false # turn on/off zstd(level 3) compression of stored objects
@ -145,6 +147,8 @@ storage:
metabase: metabase:
path: tmp/0/meta # metabase path path: tmp/0/meta # metabase path
max_batch_size: 100
max_batch_delay: 10ms
blobstor: blobstor:
path: tmp/0/blob # blobstor path 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. // to be processed in a single transactions.
// This option is missing from `bbolt.Options` but is set right after DB is open. // 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) { return func(c *cfg) {
if s != 0 {
c.boltBatchSize = s 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. // the batch of concurrent transactions is processed.
// This option is missing from `bbolt.Options` but is set right after DB is open. // 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) { return func(c *cfg) {
if d != 0 {
c.boltBatchDelay = d c.boltBatchDelay = d
} }
}
} }

View file

@ -29,7 +29,7 @@ func BenchmarkListWithCursor(b *testing.B) {
} }
func listWithCursorPrepareDB(b *testing.B) *meta.DB { 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, NoSync: true,
})) // faster single-thread generation })) // faster single-thread generation

View file

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