mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Simplify AppendSamples by allowing it to be goroutine-unsafe.
This commit is contained in:
parent
8a1c195b54
commit
fe518fdb28
|
@ -24,7 +24,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Storage ingests and manages samples, along with various indexes. All methods
|
// Storage ingests and manages samples, along with various indexes. All methods
|
||||||
// are goroutine-safe.
|
// except AppendSamples are goroutine-safe.
|
||||||
type Storage interface {
|
type Storage interface {
|
||||||
prometheus.Collector
|
prometheus.Collector
|
||||||
// AppendSamples stores a group of new samples. Multiple samples for the
|
// AppendSamples stores a group of new samples. Multiple samples for the
|
||||||
|
@ -32,7 +32,7 @@ type Storage interface {
|
||||||
// oldest to newest (both in the same call to AppendSamples and across
|
// oldest to newest (both in the same call to AppendSamples and across
|
||||||
// multiple calls). When AppendSamples has returned, the appended
|
// multiple calls). When AppendSamples has returned, the appended
|
||||||
// samples might not be queryable immediately. (Use WaitForIndexing to
|
// samples might not be queryable immediately. (Use WaitForIndexing to
|
||||||
// wait for complete processing.)
|
// wait for complete processing.) This method is not goroutine-safe.
|
||||||
AppendSamples(clientmodel.Samples)
|
AppendSamples(clientmodel.Samples)
|
||||||
// NewPreloader returns a new Preloader which allows preloading and pinning
|
// NewPreloader returns a new Preloader which allows preloading and pinning
|
||||||
// series data into memory for use within a query.
|
// series data into memory for use within a query.
|
||||||
|
|
|
@ -73,7 +73,6 @@ type memorySeriesStorage struct {
|
||||||
lastTimestampAppended clientmodel.Timestamp
|
lastTimestampAppended clientmodel.Timestamp
|
||||||
// Wait group for goroutines appending samples with the same timestamp.
|
// Wait group for goroutines appending samples with the same timestamp.
|
||||||
appendWaitGroup sync.WaitGroup
|
appendWaitGroup sync.WaitGroup
|
||||||
appendMtx sync.Mutex
|
|
||||||
|
|
||||||
persistQueue chan persistRequest
|
persistQueue chan persistRequest
|
||||||
persistStopped chan struct{}
|
persistStopped chan struct{}
|
||||||
|
@ -371,13 +370,6 @@ func (s *memorySeriesStorage) GetMetricForFingerprint(fp clientmodel.Fingerprint
|
||||||
|
|
||||||
// AppendSamples implements Storage.
|
// AppendSamples implements Storage.
|
||||||
func (s *memorySeriesStorage) AppendSamples(samples clientmodel.Samples) {
|
func (s *memorySeriesStorage) AppendSamples(samples clientmodel.Samples) {
|
||||||
if len(samples) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
s.appendMtx.Lock()
|
|
||||||
defer s.appendMtx.Unlock()
|
|
||||||
|
|
||||||
for _, sample := range samples {
|
for _, sample := range samples {
|
||||||
if sample.Timestamp != s.lastTimestampAppended {
|
if sample.Timestamp != s.lastTimestampAppended {
|
||||||
// Timestamp has changed. We have to wait for all
|
// Timestamp has changed. We have to wait for all
|
||||||
|
@ -392,7 +384,6 @@ func (s *memorySeriesStorage) AppendSamples(samples clientmodel.Samples) {
|
||||||
s.appendWaitGroup.Done()
|
s.appendWaitGroup.Done()
|
||||||
}(sample)
|
}(sample)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *memorySeriesStorage) appendSample(sample *clientmodel.Sample) {
|
func (s *memorySeriesStorage) appendSample(sample *clientmodel.Sample) {
|
||||||
|
|
Loading…
Reference in a new issue