mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
f325410c26
- Return meta-labels for the discovered targets via promutils.Labels instead of map[string]string. This improves the speed of generating meta-labels for discovered targets by up to 5x. - Remove memory allocations in hot paths during ScrapeWork generation. The ScrapeWork contains scrape settings for a single discovered target. This improves the service discovery speed by up to 2x.
21 lines
368 B
Go
21 lines
368 B
Go
package bytesutil
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
// Itoa returns string representation of n.
|
|
//
|
|
// This function doesn't allocate memory on repeated calls for the same n.
|
|
func Itoa(n int) string {
|
|
bb := bbPool.Get()
|
|
b := bb.B[:0]
|
|
b = strconv.AppendInt(b, int64(n), 10)
|
|
s := InternString(ToUnsafeString(b))
|
|
bb.B = b
|
|
bbPool.Put(bb)
|
|
return s
|
|
}
|
|
|
|
var bbPool ByteBufferPool
|