mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-07 06:37:17 +02:00
Merge 0fa3a72e84
into 25aee26a57
This commit is contained in:
commit
74b66c68d5
@ -18,11 +18,20 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/model/histogram"
|
"github.com/prometheus/prometheus/model/histogram"
|
||||||
"github.com/prometheus/prometheus/model/value"
|
"github.com/prometheus/prometheus/model/value"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// floatHistogramChunkAppenderIterPool is exclusively used in Appender() to help reduce
|
||||||
|
// allocations under heavy usage.
|
||||||
|
var floatHistogramChunkAppenderIterPool = sync.Pool{
|
||||||
|
New: func() interface{} {
|
||||||
|
return &floatHistogramIterator{}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// FloatHistogramChunk holds encoded sample data for a sparse, high-resolution
|
// FloatHistogramChunk holds encoded sample data for a sparse, high-resolution
|
||||||
// float histogram.
|
// float histogram.
|
||||||
//
|
//
|
||||||
@ -104,7 +113,8 @@ func (c *FloatHistogramChunk) Compact() {
|
|||||||
|
|
||||||
// Appender implements the Chunk interface.
|
// Appender implements the Chunk interface.
|
||||||
func (c *FloatHistogramChunk) Appender() (Appender, error) {
|
func (c *FloatHistogramChunk) Appender() (Appender, error) {
|
||||||
it := c.iterator(nil)
|
it := c.iterator(floatHistogramChunkAppenderIterPool.Get().(*floatHistogramIterator))
|
||||||
|
defer floatHistogramChunkAppenderIterPool.Put(it)
|
||||||
|
|
||||||
// To get an appender, we must know the state it would have if we had
|
// To get an appender, we must know the state it would have if we had
|
||||||
// appended all existing data from scratch. We iterate through the end
|
// appended all existing data from scratch. We iterate through the end
|
||||||
|
@ -18,11 +18,20 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/model/histogram"
|
"github.com/prometheus/prometheus/model/histogram"
|
||||||
"github.com/prometheus/prometheus/model/value"
|
"github.com/prometheus/prometheus/model/value"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// histogramChunkAppenderIterPool is exclusively used in Appender() to help reduce
|
||||||
|
// allocations under heavy usage.
|
||||||
|
var histogramChunkAppenderIterPool = sync.Pool{
|
||||||
|
New: func() interface{} {
|
||||||
|
return &histogramIterator{}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// HistogramChunk holds encoded sample data for a sparse, high-resolution
|
// HistogramChunk holds encoded sample data for a sparse, high-resolution
|
||||||
// histogram.
|
// histogram.
|
||||||
//
|
//
|
||||||
@ -115,7 +124,8 @@ func (c *HistogramChunk) Compact() {
|
|||||||
|
|
||||||
// Appender implements the Chunk interface.
|
// Appender implements the Chunk interface.
|
||||||
func (c *HistogramChunk) Appender() (Appender, error) {
|
func (c *HistogramChunk) Appender() (Appender, error) {
|
||||||
it := c.iterator(nil)
|
it := c.iterator(histogramChunkAppenderIterPool.Get().(*histogramIterator))
|
||||||
|
defer histogramChunkAppenderIterPool.Put(it)
|
||||||
|
|
||||||
// To get an appender, we must know the state it would have if we had
|
// To get an appender, we must know the state it would have if we had
|
||||||
// appended all existing data from scratch. We iterate through the end
|
// appended all existing data from scratch. We iterate through the end
|
||||||
|
@ -47,6 +47,7 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"math"
|
"math"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/model/histogram"
|
"github.com/prometheus/prometheus/model/histogram"
|
||||||
)
|
)
|
||||||
@ -55,6 +56,13 @@ const (
|
|||||||
chunkCompactCapacityThreshold = 32
|
chunkCompactCapacityThreshold = 32
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// xorAppenderIterPool is exclusively used in Appender() to help reduce allocations under heavy usage.
|
||||||
|
var xorAppenderIterPool = sync.Pool{
|
||||||
|
New: func() interface{} {
|
||||||
|
return &xorIterator{}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// XORChunk holds XOR encoded sample data.
|
// XORChunk holds XOR encoded sample data.
|
||||||
type XORChunk struct {
|
type XORChunk struct {
|
||||||
b bstream
|
b bstream
|
||||||
@ -98,7 +106,8 @@ func (c *XORChunk) Compact() {
|
|||||||
// It is not valid to call Appender() multiple times concurrently or to use multiple
|
// It is not valid to call Appender() multiple times concurrently or to use multiple
|
||||||
// Appenders on the same chunk.
|
// Appenders on the same chunk.
|
||||||
func (c *XORChunk) Appender() (Appender, error) {
|
func (c *XORChunk) Appender() (Appender, error) {
|
||||||
it := c.iterator(nil)
|
it := c.iterator(xorAppenderIterPool.Get().(*xorIterator))
|
||||||
|
defer xorAppenderIterPool.Put(it)
|
||||||
|
|
||||||
// To get an appender we must know the state it would have if we had
|
// To get an appender we must know the state it would have if we had
|
||||||
// appended all existing data from scratch.
|
// appended all existing data from scratch.
|
||||||
|
Loading…
Reference in New Issue
Block a user