github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/convert/pprof/streaming/labels_cache_arenas_enabled.go (about) 1 //go:build goexperiment.arenas 2 3 package streaming 4 5 import ( 6 "github.com/pyroscope-io/pyroscope/pkg/storage/tree" 7 "github.com/pyroscope-io/pyroscope/pkg/util/arenahelper" 8 ) 9 10 func (c *LabelsCache) newCacheEntryA(l Labels) (int, *tree.Tree) { 11 a := c.arena 12 if a == nil { 13 return c.newCacheEntry(l) 14 } 15 from := len(c.labels) 16 for _, u := range l { 17 if len(c.labels) < cap(c.labels) { 18 c.labels = append(c.labels, u) 19 } else { 20 c.labels = arenahelper.AppendA(c.labels, u, a) 21 } 22 } 23 to := len(c.labels) 24 res := len(c.labelRefs) 25 r := uint64(from<<32 | to) 26 if len(c.labelRefs) < cap(c.labelRefs) { 27 c.labelRefs = append(c.labelRefs, r) 28 } else { 29 c.labelRefs = arenahelper.AppendA(c.labelRefs, r, a) 30 } 31 t := tree.NewA(a) 32 if len(c.trees) < cap(c.trees) { 33 c.trees = append(c.trees, t) 34 } else { 35 c.trees = arenahelper.AppendA(c.trees, t, a) 36 } 37 return res, t 38 }