app/vmstorage/transport: reduce memory allocations on data ingestion path

This commit is contained in:
Aliaksandr Valialkin 2021-04-10 17:35:45 +03:00
parent 19906dc30e
commit 0f7ece84f3

View file

@ -395,7 +395,7 @@ type unmarshalWork struct {
} }
func (uw *unmarshalWork) reset() { func (uw *unmarshalWork) reset() {
if (len(uw.mrs)*4 > cap(uw.mrs) || len(uw.reqBuf)*4 > cap(uw.reqBuf)) && fasttime.UnixTimestamp()-uw.lastResetTime > 10 { if len(uw.reqBuf)*4 < cap(uw.reqBuf) && fasttime.UnixTimestamp()-uw.lastResetTime > 10 {
// Periodically reset mrs and reqBuf in order to prevent from gradual memory usage growth // Periodically reset mrs and reqBuf in order to prevent from gradual memory usage growth
// when ceratin entries in mr contain too long labels. // when ceratin entries in mr contain too long labels.
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/490 for details. // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/490 for details.