mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: do not append headerData to bsw.indexData if its size exceeds maxBlockSize
This is a follow-up optimization after 3c246cdf00
This commit is contained in:
parent
7eb5c187b3
commit
2eb967231b
1 changed files with 5 additions and 5 deletions
|
@ -135,6 +135,7 @@ func (bsw *blockStreamWriter) WriteExternalBlock(b *Block, ph *partHeader, rowsM
|
|||
atomic.AddUint64(rowsMerged, uint64(b.rowsCount()))
|
||||
b.deduplicateSamplesDuringMerge()
|
||||
headerData, timestampsData, valuesData := b.MarshalData(bsw.timestampsBlockOffset, bsw.valuesBlockOffset)
|
||||
|
||||
usePrevTimestamps := len(bsw.prevTimestampsData) > 0 && bytes.Equal(timestampsData, bsw.prevTimestampsData)
|
||||
if usePrevTimestamps {
|
||||
// The current timestamps block equals to the previous timestamps block.
|
||||
|
@ -143,14 +144,13 @@ func (bsw *blockStreamWriter) WriteExternalBlock(b *Block, ph *partHeader, rowsM
|
|||
atomic.AddUint64(×tampsBlocksMerged, 1)
|
||||
atomic.AddUint64(×tampsBytesSaved, uint64(len(timestampsData)))
|
||||
}
|
||||
indexDataLen := len(bsw.indexData)
|
||||
bsw.indexData = append(bsw.indexData, headerData...)
|
||||
if len(bsw.indexData) > maxBlockSize {
|
||||
bsw.indexData = bsw.indexData[:indexDataLen]
|
||||
|
||||
if len(bsw.indexData)+len(headerData) > maxBlockSize {
|
||||
bsw.flushIndexData()
|
||||
bsw.indexData = append(bsw.indexData, headerData...)
|
||||
}
|
||||
bsw.indexData = append(bsw.indexData, headerData...)
|
||||
bsw.mr.RegisterBlockHeader(&b.bh)
|
||||
|
||||
if !usePrevTimestamps {
|
||||
bsw.prevTimestampsData = append(bsw.prevTimestampsData[:0], timestampsData...)
|
||||
bsw.prevTimestampsBlockOffset = bsw.timestampsBlockOffset
|
||||
|
|
Loading…
Reference in a new issue