forked from TrueCloudLab/frostfs-node
[#1367] writecache: Add background flushing objects limiter
To limit memory usage by background flush. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
8a6e3025a0
commit
e39378b1c3
12 changed files with 184 additions and 35 deletions
|
@ -154,6 +154,7 @@ type shardCfg struct {
|
|||
countLimit uint64
|
||||
noSync bool
|
||||
pageSize int
|
||||
flushSizeLimit uint64
|
||||
}
|
||||
|
||||
piloramaCfg struct {
|
||||
|
@ -278,6 +279,7 @@ func (a *applicationConfiguration) setShardWriteCacheConfig(newConfig *shardCfg,
|
|||
wc.sizeLimit = writeCacheCfg.SizeLimit()
|
||||
wc.countLimit = writeCacheCfg.CountLimit()
|
||||
wc.noSync = writeCacheCfg.NoSync()
|
||||
wc.flushSizeLimit = writeCacheCfg.MaxFlushingObjectsSize()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -865,6 +867,7 @@ func (c *cfg) getWriteCacheOpts(shCfg shardCfg) []writecache.Option {
|
|||
writecache.WithMaxBatchSize(wcRead.maxBatchSize),
|
||||
writecache.WithMaxBatchDelay(wcRead.maxBatchDelay),
|
||||
writecache.WithPageSize(wcRead.pageSize),
|
||||
writecache.WithFlushSizeLimit(wcRead.flushSizeLimit),
|
||||
writecache.WithMaxObjectSize(wcRead.maxObjSize),
|
||||
writecache.WithSmallObjectSize(wcRead.smallObjectSize),
|
||||
writecache.WithFlushWorkersCount(wcRead.flushWorkerCount),
|
||||
|
|
|
@ -79,6 +79,7 @@ func TestEngineSection(t *testing.T) {
|
|||
require.EqualValues(t, 3221225472, wc.SizeLimit())
|
||||
require.EqualValues(t, 4096, wc.BoltDB().PageSize())
|
||||
require.EqualValues(t, 49, wc.CountLimit())
|
||||
require.EqualValues(t, uint64(100), wc.MaxFlushingObjectsSize())
|
||||
|
||||
require.Equal(t, "tmp/0/meta", meta.Path())
|
||||
require.Equal(t, fs.FileMode(0o644), meta.BoltDB().Perm())
|
||||
|
@ -136,6 +137,7 @@ func TestEngineSection(t *testing.T) {
|
|||
require.EqualValues(t, 4294967296, wc.SizeLimit())
|
||||
require.EqualValues(t, 0, wc.BoltDB().PageSize())
|
||||
require.EqualValues(t, writecacheconfig.CountLimitDefault, wc.CountLimit())
|
||||
require.EqualValues(t, writecacheconfig.MaxFlushingObjectsSizeDefault, wc.MaxFlushingObjectsSize())
|
||||
|
||||
require.Equal(t, "tmp/1/meta", meta.Path())
|
||||
require.Equal(t, fs.FileMode(0o644), meta.BoltDB().Perm())
|
||||
|
|
|
@ -24,6 +24,8 @@ const (
|
|||
|
||||
// CountLimitDefault is a default write-cache count limit.
|
||||
CountLimitDefault = 0
|
||||
|
||||
MaxFlushingObjectsSizeDefault = 128 << 20
|
||||
)
|
||||
|
||||
// From wraps config section into Config.
|
||||
|
@ -145,3 +147,19 @@ func (x *Config) NoSync() bool {
|
|||
func (x *Config) BoltDB() *boltdbconfig.Config {
|
||||
return (*boltdbconfig.Config)(x)
|
||||
}
|
||||
|
||||
// MaxFlushingObjectsSize returns the value of "max_flushing_objects_size" config parameter.
|
||||
//
|
||||
// Returns MaxFlushingObjectsSizeDefault if the value is not a positive number.
|
||||
func (x *Config) MaxFlushingObjectsSize() uint64 {
|
||||
s := config.SizeInBytesSafe(
|
||||
(*config.Config)(x),
|
||||
"max_flushing_objects_size",
|
||||
)
|
||||
|
||||
if s > 0 {
|
||||
return s
|
||||
}
|
||||
|
||||
return MaxFlushingObjectsSizeDefault
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue