mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/{mergeset,storage}: take into account byte slice capacity when returning the size of in-memory part
This results in more correct reporting of memory usage for in-memory parts
This commit is contained in:
parent
c4150995ad
commit
f3e3a3daeb
2 changed files with 8 additions and 6 deletions
|
@ -76,9 +76,8 @@ var inmemoryPartBytePool bytesutil.ByteBufferPool
|
|||
// It is safe calling NewPart multiple times.
|
||||
// It is unsafe re-using mp while the returned part is in use.
|
||||
func (mp *inmemoryPart) NewPart() *part {
|
||||
ph := mp.ph
|
||||
size := mp.size()
|
||||
p, err := newPart(&ph, "", size, mp.metaindexData.NewReader(), &mp.indexData, &mp.itemsData, &mp.lensData)
|
||||
p, err := newPart(&mp.ph, "", size, mp.metaindexData.NewReader(), &mp.indexData, &mp.itemsData, &mp.lensData)
|
||||
if err != nil {
|
||||
logger.Panicf("BUG: cannot create a part from inmemoryPart: %s", err)
|
||||
}
|
||||
|
@ -86,5 +85,5 @@ func (mp *inmemoryPart) NewPart() *part {
|
|||
}
|
||||
|
||||
func (mp *inmemoryPart) size() uint64 {
|
||||
return uint64(len(mp.metaindexData.B) + len(mp.indexData.B) + len(mp.itemsData.B) + len(mp.lensData.B))
|
||||
return uint64(cap(mp.metaindexData.B) + cap(mp.indexData.B) + cap(mp.itemsData.B) + cap(mp.lensData.B))
|
||||
}
|
||||
|
|
|
@ -49,9 +49,12 @@ func (mp *inmemoryPart) InitFromRows(rows []rawRow) {
|
|||
// It is safe calling NewPart multiple times.
|
||||
// It is unsafe re-using mp while the returned part is in use.
|
||||
func (mp *inmemoryPart) NewPart() (*part, error) {
|
||||
ph := mp.ph
|
||||
size := uint64(len(mp.timestampsData.B) + len(mp.valuesData.B) + len(mp.indexData.B) + len(mp.metaindexData.B))
|
||||
return newPart(&ph, "", size, mp.metaindexData.NewReader(), &mp.timestampsData, &mp.valuesData, &mp.indexData)
|
||||
size := mp.size()
|
||||
return newPart(&mp.ph, "", size, mp.metaindexData.NewReader(), &mp.timestampsData, &mp.valuesData, &mp.indexData)
|
||||
}
|
||||
|
||||
func (mp *inmemoryPart) size() uint64 {
|
||||
return uint64(cap(mp.timestampsData.B) + cap(mp.valuesData.B) + cap(mp.indexData.B) + cap(mp.metaindexData.B))
|
||||
}
|
||||
|
||||
func getInmemoryPart() *inmemoryPart {
|
||||
|
|
Loading…
Reference in a new issue