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
|
@ -40,7 +40,9 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||
shardmode "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
||||
writecacheconfig "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/config"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/writecachebadger"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/writecachebbolt"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||
containerClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/container"
|
||||
|
@ -127,6 +129,7 @@ type shardCfg struct {
|
|||
|
||||
writecacheCfg struct {
|
||||
enabled bool
|
||||
typ writecacheconfig.Type
|
||||
path string
|
||||
maxBatchSize int
|
||||
maxBatchDelay time.Duration
|
||||
|
@ -135,6 +138,7 @@ type shardCfg struct {
|
|||
flushWorkerCount int
|
||||
sizeLimit uint64
|
||||
noSync bool
|
||||
gcInterval time.Duration
|
||||
}
|
||||
|
||||
piloramaCfg struct {
|
||||
|
@ -238,6 +242,7 @@ func (a *applicationConfiguration) setShardWriteCacheConfig(newConfig *shardCfg,
|
|||
wc := &newConfig.writecacheCfg
|
||||
|
||||
wc.enabled = true
|
||||
wc.typ = writeCacheCfg.Type()
|
||||
wc.path = writeCacheCfg.Path()
|
||||
wc.maxBatchSize = writeCacheCfg.BoltDB().MaxBatchSize()
|
||||
wc.maxBatchDelay = writeCacheCfg.BoltDB().MaxBatchDelay()
|
||||
|
@ -246,6 +251,7 @@ func (a *applicationConfiguration) setShardWriteCacheConfig(newConfig *shardCfg,
|
|||
wc.flushWorkerCount = writeCacheCfg.WorkersNumber()
|
||||
wc.sizeLimit = writeCacheCfg.SizeLimit()
|
||||
wc.noSync = writeCacheCfg.NoSync()
|
||||
wc.gcInterval = writeCacheCfg.GCInterval()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -704,20 +710,37 @@ func (c *cfg) shardOpts() []shardOptsWithID {
|
|||
return shards
|
||||
}
|
||||
|
||||
func (c *cfg) getWriteCacheOpts(shCfg shardCfg) []writecache.Option {
|
||||
var writeCacheOpts []writecache.Option
|
||||
func (c *cfg) getWriteCacheOpts(shCfg shardCfg) writecacheconfig.Options {
|
||||
var writeCacheOpts writecacheconfig.Options
|
||||
if wcRead := shCfg.writecacheCfg; wcRead.enabled {
|
||||
writeCacheOpts = append(writeCacheOpts,
|
||||
writecache.WithPath(wcRead.path),
|
||||
writecache.WithMaxBatchSize(wcRead.maxBatchSize),
|
||||
writecache.WithMaxBatchDelay(wcRead.maxBatchDelay),
|
||||
writecache.WithMaxObjectSize(wcRead.maxObjSize),
|
||||
writecache.WithSmallObjectSize(wcRead.smallObjectSize),
|
||||
writecache.WithFlushWorkersCount(wcRead.flushWorkerCount),
|
||||
writecache.WithMaxCacheSize(wcRead.sizeLimit),
|
||||
writecache.WithNoSync(wcRead.noSync),
|
||||
writecache.WithLogger(c.log),
|
||||
)
|
||||
switch wcRead.typ {
|
||||
case writecacheconfig.TypeBBolt:
|
||||
writeCacheOpts.Type = writecacheconfig.TypeBBolt
|
||||
writeCacheOpts.BBoltOptions = append(writeCacheOpts.BBoltOptions,
|
||||
writecachebbolt.WithPath(wcRead.path),
|
||||
writecachebbolt.WithMaxBatchSize(wcRead.maxBatchSize),
|
||||
writecachebbolt.WithMaxBatchDelay(wcRead.maxBatchDelay),
|
||||
writecachebbolt.WithMaxObjectSize(wcRead.maxObjSize),
|
||||
writecachebbolt.WithSmallObjectSize(wcRead.smallObjectSize),
|
||||
writecachebbolt.WithFlushWorkersCount(wcRead.flushWorkerCount),
|
||||
writecachebbolt.WithMaxCacheSize(wcRead.sizeLimit),
|
||||
writecachebbolt.WithNoSync(wcRead.noSync),
|
||||
writecachebbolt.WithLogger(c.log),
|
||||
)
|
||||
case writecacheconfig.TypeBadger:
|
||||
writeCacheOpts.Type = writecacheconfig.TypeBBolt
|
||||
writeCacheOpts.BadgerOptions = append(writeCacheOpts.BadgerOptions,
|
||||
writecachebadger.WithPath(wcRead.path),
|
||||
writecachebadger.WithMaxObjectSize(wcRead.maxObjSize),
|
||||
writecachebadger.WithFlushWorkersCount(wcRead.flushWorkerCount),
|
||||
writecachebadger.WithMaxCacheSize(wcRead.sizeLimit),
|
||||
writecachebadger.WithNoSync(wcRead.noSync),
|
||||
writecachebadger.WithLogger(c.log),
|
||||
writecachebadger.WithGCInterval(wcRead.gcInterval),
|
||||
)
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown writecache type: %q", wcRead.typ))
|
||||
}
|
||||
}
|
||||
return writeCacheOpts
|
||||
}
|
||||
|
@ -836,7 +859,7 @@ func (c *cfg) getShardOpts(shCfg shardCfg) shardOptsWithID {
|
|||
shard.WithMetaBaseOptions(mbOptions...),
|
||||
shard.WithPiloramaOptions(piloramaOpts...),
|
||||
shard.WithWriteCache(shCfg.writecacheCfg.enabled),
|
||||
shard.WithWriteCacheOptions(writeCacheOpts...),
|
||||
shard.WithWriteCacheOptions(writeCacheOpts),
|
||||
shard.WithRemoverBatchSize(shCfg.gcCfg.removerBatchSize),
|
||||
shard.WithGCRemoverSleepInterval(shCfg.gcCfg.removerSleepInterval),
|
||||
shard.WithExpiredCollectorBatchSize(shCfg.gcCfg.expiredCollectorBatchSize),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue