Repository navigation
Conversation
bwplotka
force-pushed
the
bwplotka/om-scrape-bench
branch
from
October 3, 2026 22:43
2dc087f to
1e6c827
Compare
Needed for expfmt.MetricFamilyToOpenMetrics20 summary support, used by the scrape benchmarks to generate OpenMetrics 2.0 payloads from the Prometheus text test data. Signed-off-by: Bartek Plotka <[email protected]>
…rics page BenchmarkScrapeLoopAppend gains an OMText2 format, a parseST dimension and two datasets built from a real Prometheus server page, and drops the AppenderV1 case. Datasets are now declared once (benchDatasets) with the payload per format, and TestBenchDatasets checks that every format of a dataset appends the same number of samples, so the benchmark compares equal work. prometheus.om1.txt is the /metrics page of prometheus.demo.prometheus.io (265 families: 123 counters, 105 gauges, 24 histograms, 13 summaries) in OpenMetrics 1.0 with a _created line for every counter, summary and histogram, as client_golang exposes them. prometheus.om2.txt is the same page in OpenMetrics 2.0 with the start timestamps inline (st@). Both were generated with expfmt from the same parsed families, with the created timestamp set to the page's process_start_time_seconds. The synthetic 237FamsAllTypes page (6 _created lines for 142 eligible families) is replaced by it in this benchmark: with parseST=true OM 1.0 spends almost all of its time re-lexing for _created lines that are not there (150 ms vs 4 ms on the real page), which hides every other difference between the parsers. The OM 2.0 payload of the gauge dataset is generated with expfmt.MetricFamilyToOpenMetrics20, hence the prometheus/common bump. Signed-off-by: Bartek Plotka <[email protected]>
bwplotka
force-pushed
the
bwplotka/om-scrape-bench
branch
from
October 4, 2026 11:26
1e6c827 to
a5ee37c
Compare
dashpole
reviewed
Oct 5, 2026
| sl.alwaysScrapeClassicHist = false | ||
| sl.enableOpenMetrics2 = true | ||
| // Only AppenderV2 uses parseST; false skips p.StartTimestamp() entirely. | ||
| sl.parseST = parseST |
Contributor
There was a problem hiding this comment.
Its true that false skips the start timestamp, but in that case it still ingests the _created series as regular series. So with parseST=false it isn't quite comparing apples to apples.
Member
Author
There was a problem hiding this comment.
I disagree.
OM1 specifies optional _created lines, so we should benchmark the full spec, even if e.g. Go does not produce those lines by default (against the spec). Default path is scraper is to collect all without ST parsing, so that would be the full effect.
Not all data inputs have _created lines so we can ensure we have no _created line comparision too.
Member
Author
|
This has been merged in #19907 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an OpenMetrics 2.0 case to
BenchmarkScrapeLoopAppendso we can compare OM 1.0 and OM 2.0 scraping end to end (parse + append) on a realistic page rather than only the synthetic 2000-gauge one.Commits, in reading order:
build: bump prometheus/common to v0.72.0: needed forexpfmt.MetricFamilyToOpenMetrics20summary support, used to generate the OM 2.0 payloads.scrape: benchmark OM 1.0 vs OM 2.0 scraping of a real Prometheus /metrics page: the benchmark itself.What changed in the benchmark:
fmt=OMText2case and aparseST=<bool>dimension (EnableStartTimestampParsing).appV2dimension is gone; the benchmark always uses AppenderV2. AppenderV2 is the Prometheus default (prometheus/scrape/manager.go
Line 136 in 961c9ba
prometheus/scrape/manager.go
Line 121 in 961c9ba
parseSTonly exists on the V2 path, so keepingappV2=falsedoubled the matrix (already 6 dimensions) for a code path Prometheus itself does not run and that cannot exercise the ST difference this benchmark is about.benchDatasetswith the payload per format, andTestBenchDatasetsasserts every format of a dataset appends the same number of samples, so the formats are compared on equal work.model/textparse/testdata/prometheus.om1.txtis the/metricspage ofprometheus.demo.prometheus.io(265 families: 123 counters, 105 gauges, 24 histograms, 13 summaries) in OM 1.0 with a_createdline for every counter, summary and histogram, as client_golang exposes them.prometheus.om2.txtis the same page in OM 2.0 with start timestamps inline (st@). Both were generated withexpfmtfrom the same parsed families, with the created timestamp set to the page'sprocess_start_time_seconds.265FamsPrometheusNHCBis the same page withconvertClassicHistogramsToNHCB. The synthetic237FamsAllTypespage is dropped from this benchmark: it has 6_createdlines for 142 eligible families, so withparseST=trueOM 1.0 spends almost all of its time re-lexing for_createdlines that are not there (150 ms vs 4 ms on the real page), which hides every other difference.The benchmark name is now
withStorage=%v/appendMetadataToWAL=%v/data=%v/fmt=%v/coldCache=%v/parseST=%v. Beware that-benchmatches each/segment unanchored, sofmt=OMTextalso selectsfmt=OMText2; the recommended invocation in the comment anchors withfmt=OMText$.Numbers on current
mainplus 55bb7924c1 (the small pooling fix I am sending separately; it does not change the picture below).withStorage=false,appendMetadataToWAL=false,-benchtime 2s -count 6 -cpu 2, OM 1.0 and OM 2.0 run as separate processes,benchstat -col /fmt:What this already surfaces, which is the point of having it in tree:
_createdlines.parseST=false, OM 2.0 is still ~9% slower and allocates 178 KiB vs 3 KiB per warm scrape, because the OM 2.0 parser onmainbuilds labels eagerly for every exploded histogram/summary series. textparse [PERF]: defer OM2 composite and exemplar label allocations #19895 addresses that.