mirror of https://github.com/prometheus/prometheus
perf(nhcbparse): unroll recursion (#15776)
https://github.com/prometheus/prometheus/pull/15467#issuecomment-2563585979 Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>pull/15467/head
parent
1e420ef373
commit
cfcb00a716
|
@ -177,13 +177,14 @@ func (p *NHCBParser) CreatedTimestamp() *int64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *NHCBParser) Next() (Entry, error) {
|
func (p *NHCBParser) Next() (Entry, error) {
|
||||||
|
for {
|
||||||
if p.state == stateEmitting {
|
if p.state == stateEmitting {
|
||||||
p.state = stateStart
|
p.state = stateStart
|
||||||
if p.entry == EntrySeries {
|
if p.entry == EntrySeries {
|
||||||
isNHCB := p.handleClassicHistogramSeries(p.lset)
|
isNHCB := p.handleClassicHistogramSeries(p.lset)
|
||||||
if isNHCB && !p.keepClassicHistograms {
|
if isNHCB && !p.keepClassicHistograms {
|
||||||
// Do not return the classic histogram series if it was converted to NHCB and we are not keeping classic histograms.
|
// Do not return the classic histogram series if it was converted to NHCB and we are not keeping classic histograms.
|
||||||
return p.Next()
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return p.entry, p.err
|
return p.entry, p.err
|
||||||
|
@ -218,7 +219,7 @@ func (p *NHCBParser) Next() (Entry, error) {
|
||||||
}
|
}
|
||||||
if isNHCB && !p.keepClassicHistograms {
|
if isNHCB && !p.keepClassicHistograms {
|
||||||
// Do not return the classic histogram series if it was converted to NHCB and we are not keeping classic histograms.
|
// Do not return the classic histogram series if it was converted to NHCB and we are not keeping classic histograms.
|
||||||
return p.Next()
|
continue
|
||||||
}
|
}
|
||||||
return p.entry, p.err
|
return p.entry, p.err
|
||||||
case EntryHistogram:
|
case EntryHistogram:
|
||||||
|
@ -233,6 +234,7 @@ func (p *NHCBParser) Next() (Entry, error) {
|
||||||
}
|
}
|
||||||
return p.entry, p.err
|
return p.entry, p.err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return true if labels have changed and we should emit the NHCB.
|
// Return true if labels have changed and we should emit the NHCB.
|
||||||
func (p *NHCBParser) compareLabels() bool {
|
func (p *NHCBParser) compareLabels() bool {
|
||||||
|
|
Loading…
Reference in New Issue