testing a lil optimization

Signed-off-by: Owen Williams <owen.williams@grafana.com>
This commit is contained in:
Owen Williams 2026-02-03 13:56:56 -05:00
parent 304dcdf695
commit 7ca860ee50
No known key found for this signature in database
GPG key ID: 711C61A216D34A69
2 changed files with 8 additions and 4 deletions

View file

@ -724,6 +724,8 @@ func isV2TimeSeriesOldFilter(metrics *queueManagerMetrics, baseTime time.Time, s
// enqueued on their shards or a shutdown signal is received.
func (t *QueueManager) Append(samples []record.RefSample) bool {
currentTime := time.Now()
var tseries timeSeries
var meta *metadata.Metadata
outer:
for _, s := range samples {
if isSampleOld(currentTime, time.Duration(t.cfg.SampleAgeLimit), s.T) {
@ -745,26 +747,28 @@ outer:
}
// TODO(cstyan): Handle or at least log an error if no metadata is found.
// See https://github.com/prometheus/prometheus/issues/14405
meta := t.seriesMetadata[s.Ref]
meta = t.seriesMetadata[s.Ref]
t.seriesMtx.Unlock()
// Start with a very small backoff. This should not be t.cfg.MinBackoff
// as it can happen without errors, and we want to pickup work after
// filling a queue/resharding as quickly as possible.
// TODO: Consider using the average duration of a request as the backoff.
backoff := model.Duration(5 * time.Millisecond)
for {
select {
case <-t.quit:
return false
default:
}
if t.shards.enqueue(s.Ref, timeSeries{
tseries = timeSeries{
seriesLabels: lbls,
metadata: meta,
timestamp: s.T,
value: s.V,
sType: tSample,
}) {
}
if t.shards.enqueue(s.Ref, tseries) {
continue outer
}

View file

@ -161,7 +161,7 @@ type RefSeries struct {
// TODO(beorn7): Perhaps make this "polymorphic", including histogram and float-histogram pointers? Then get rid of RefHistogramSample.
type RefSample struct {
Ref chunks.HeadSeriesRef
T int64
ST, T int64
V float64
}