mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/{mergeset,storage}: tune compression levels for small blocks
This should reduce CPU usage spent on compression
This commit is contained in:
parent
e757ebc58b
commit
59877d9f32
2 changed files with 9 additions and 1 deletions
|
@ -50,7 +50,8 @@ func (mp *inmemoryPart) Init(ib *inmemoryBlock) {
|
|||
|
||||
// Use the minimum possible compressLevel for compressing inmemoryPart,
|
||||
// since it will be merged into file part soon.
|
||||
compressLevel := 0
|
||||
// See https://github.com/facebook/zstd/releases/tag/v1.3.4 for details about negative compression level
|
||||
compressLevel := -5
|
||||
mp.bh.firstItem, mp.bh.commonPrefix, mp.bh.itemsCount, mp.bh.marshalType = ib.MarshalUnsortedData(&mp.sb, mp.bh.firstItem[:0], mp.bh.commonPrefix[:0], compressLevel)
|
||||
|
||||
mp.ph.itemsCount = uint64(len(ib.items))
|
||||
|
|
|
@ -1255,6 +1255,13 @@ func (pt *partition) mergeParts(pws []*partWrapper, stopCh <-chan struct{}) erro
|
|||
|
||||
func getCompressLevelForRowsCount(rowsCount, blocksCount uint64) int {
|
||||
avgRowsPerBlock := rowsCount / blocksCount
|
||||
// See https://github.com/facebook/zstd/releases/tag/v1.3.4 about negative compression levels.
|
||||
if avgRowsPerBlock <= 10 {
|
||||
return -5
|
||||
}
|
||||
if avgRowsPerBlock <= 50 {
|
||||
return -2
|
||||
}
|
||||
if avgRowsPerBlock <= 200 {
|
||||
return -1
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue