Simplify AppendSamples by allowing it to be goroutine-unsafe.

pull/524/head
beorn7 2015-02-13 12:12:07 +01:00
parent 8a1c195b54
commit fe518fdb28
2 changed files with 2 additions and 11 deletions

View File

@ -24,7 +24,7 @@ import (
)
// Storage ingests and manages samples, along with various indexes. All methods
// are goroutine-safe.
// except AppendSamples are goroutine-safe.
type Storage interface {
prometheus.Collector
// 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
// multiple calls). When AppendSamples has returned, the appended
// 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)
// NewPreloader returns a new Preloader which allows preloading and pinning
// series data into memory for use within a query.

View File

@ -73,7 +73,6 @@ type memorySeriesStorage struct {
lastTimestampAppended clientmodel.Timestamp
// Wait group for goroutines appending samples with the same timestamp.
appendWaitGroup sync.WaitGroup
appendMtx sync.Mutex
persistQueue chan persistRequest
persistStopped chan struct{}
@ -371,13 +370,6 @@ func (s *memorySeriesStorage) GetMetricForFingerprint(fp clientmodel.Fingerprint
// AppendSamples implements Storage.
func (s *memorySeriesStorage) AppendSamples(samples clientmodel.Samples) {
if len(samples) == 0 {
return
}
s.appendMtx.Lock()
defer s.appendMtx.Unlock()
for _, sample := range samples {
if sample.Timestamp != s.lastTimestampAppended {
// Timestamp has changed. We have to wait for all
@ -392,7 +384,6 @@ func (s *memorySeriesStorage) AppendSamples(samples clientmodel.Samples) {
s.appendWaitGroup.Done()
}(sample)
}
}
func (s *memorySeriesStorage) appendSample(sample *clientmodel.Sample) {