mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01: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
886ce94739
commit
7ffa66d249
@ -76,9 +76,8 @@ var inmemoryPartBytePool bytesutil.ByteBufferPool
|
|||||||
// It is safe calling NewPart multiple times.
|
// It is safe calling NewPart multiple times.
|
||||||
// It is unsafe re-using mp while the returned part is in use.
|
// It is unsafe re-using mp while the returned part is in use.
|
||||||
func (mp *inmemoryPart) NewPart() *part {
|
func (mp *inmemoryPart) NewPart() *part {
|
||||||
ph := mp.ph
|
|
||||||
size := mp.size()
|
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 {
|
if err != nil {
|
||||||
logger.Panicf("BUG: cannot create a part from inmemoryPart: %s", err)
|
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 {
|
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 safe calling NewPart multiple times.
|
||||||
// It is unsafe re-using mp while the returned part is in use.
|
// It is unsafe re-using mp while the returned part is in use.
|
||||||
func (mp *inmemoryPart) NewPart() (*part, error) {
|
func (mp *inmemoryPart) NewPart() (*part, error) {
|
||||||
ph := mp.ph
|
size := mp.size()
|
||||||
size := uint64(len(mp.timestampsData.B) + len(mp.valuesData.B) + len(mp.indexData.B) + len(mp.metaindexData.B))
|
return newPart(&mp.ph, "", size, mp.metaindexData.NewReader(), &mp.timestampsData, &mp.valuesData, &mp.indexData)
|
||||||
return newPart(&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 {
|
func getInmemoryPart() *inmemoryPart {
|
||||||
|
Loading…
Reference in New Issue
Block a user