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
George Krajcsovits 2025-01-02 15:51:52 +01:00 committed by GitHub
parent 1e420ef373
commit cfcb00a716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 48 additions and 46 deletions

View File

@ -177,13 +177,14 @@ func (p *NHCBParser) CreatedTimestamp() *int64 {
}
func (p *NHCBParser) Next() (Entry, error) {
for {
if p.state == stateEmitting {
p.state = stateStart
if p.entry == EntrySeries {
isNHCB := p.handleClassicHistogramSeries(p.lset)
if isNHCB && !p.keepClassicHistograms {
// 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
@ -218,7 +219,7 @@ func (p *NHCBParser) Next() (Entry, error) {
}
if isNHCB && !p.keepClassicHistograms {
// 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
case EntryHistogram:
@ -233,6 +234,7 @@ func (p *NHCBParser) Next() (Entry, error) {
}
return p.entry, p.err
}
}
// Return true if labels have changed and we should emit the NHCB.
func (p *NHCBParser) compareLabels() bool {