Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
make []schema.Point msgp decoding use the pointslicepool
Browse files Browse the repository at this point in the history
this should help reduce memory usage in query nodes when they decode
/getdata requests coming back
  • Loading branch information
Dieterbe committed Oct 15, 2020
1 parent 56f0106 commit de35bcf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions api/models/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package models

import "github.com/grafana/metrictank/pointslicepool"

func init() {
pointSlicePool = pointslicepool.New(100)
}
5 changes: 2 additions & 3 deletions api/models/series_msgp_manual.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package models

import (
"github.com/grafana/metrictank/schema"
"github.com/tinylib/msgp/msgp"
)

Expand Down Expand Up @@ -136,7 +135,7 @@ func (z *Series) DecodeMsg(dc *msgp.Reader) (err error) {
if cap(z.Datapoints) >= int(zb0004) {
z.Datapoints = (z.Datapoints)[:zb0004]
} else {
z.Datapoints = make([]schema.Point, zb0004)
z.Datapoints = pointSlicePool.GetMin(int(zb0004))[:zb0004]
}
for za0004 := range z.Datapoints {
err = z.Datapoints[za0004].DecodeMsg(dc)
Expand Down Expand Up @@ -512,7 +511,7 @@ func (z *Series) UnmarshalMsg(bts []byte) (o []byte, err error) {
if cap(z.Datapoints) >= int(zb0004) {
z.Datapoints = (z.Datapoints)[:zb0004]
} else {
z.Datapoints = make([]schema.Point, zb0004)
z.Datapoints = pointSlicePool.GetMin(int(zb0004))[:zb0004]
}
for za0004 := range z.Datapoints {
bts, err = z.Datapoints[za0004].UnmarshalMsg(bts)
Expand Down

0 comments on commit de35bcf

Please sign in to comment.