Repository navigation
expfmt: bump go-abnf to v0.5.5 - #1029
Conversation
The OpenMetrics decoder parses every line with goabnf.ParseForest, which is cubic in the input length. A valid 4 KiB label value took ~17s to decode on v0.5.3. go-abnf v0.5.5 adds the lookahead that avoids the useless paths (pandatix/go-abnf#277). Bump the dependency; go.sum follows. Ref #1028 Signed-off-by: PerryLink <novelnexusai@outlook.com>
e78822e to
57d6f60
Compare
|
One more data point for this bump, from the OpenMetrics 2.0 decoder that landed in #1016: it has the same uncapped dec := expfmt.NewDecoder(bytes.NewReader(bytes.Repeat([]byte("l"), n)), expfmt.FmtOpenMetrics_2_0_0)
dec.Decode(&dto.MetricFamily{})
(Go 1.26.10, linux/amd64. The line is not valid OpenMetrics — it is a single long token — so the decoder pays the parse cost before rejecting it, which is the untrusted-input case from #1028.) A |
SuperQ
left a comment
There was a problem hiding this comment.
Thanks. Typically we just use dependabot to maintain these updates.
What's Changed * expfmt: add ABNF parser for OpenMetrics 2.0 by @bwplotka in #1016 * build(deps): bump ossf/scorecard-action from 2.4.4 to 2.5.0 by @dependabot[bot] in #1032 * build(deps): bump actions/upload-artifact from 7.0.1 to 7.0.2 by @dependabot[bot] in #1033 * build(deps): bump golang.org/x/net from 0.61.0 to 0.62.0 in the golang-org-x group across 1 directory by @dependabot[bot] in #1030 * expfmt: bump go-abnf to v0.5.5 by @PerryLink in #1029 * config: move Secret into its own package by @mrueg in #1024 * build(deps): bump the codeql group with 4 updates by @dependabot[bot] in #1031 * version: fix Slog godoc example to compile by @sueun-dev in #935 * build(deps): bump go.yaml.in/yaml/v2 from 2.4.4 to 2.4.5 by @dependabot[bot] in #1043 * build(deps): bump golang.org/x/oauth2 from 0.37.0 to 0.38.0 in the golang-org-x group across 1 directory by @dependabot[bot] in #1042 * expfmt: support Prometheus text format 1.0.0 by @ArthurSens in #1035 New Contributors * @PerryLink made their first contribution in #1029 * @sueun-dev made their first contribution in #935 **Full Changelog**: v0.73.1...v0.74.0 Signed-off-by: SuperQ <superq@gmail.com>
What
Bumps
github.com/pandatix/go-abnffrom v0.5.3 to v0.5.5.Why
After #1015/#1016,
expfmt.NewDecoderparses every OpenMetrics line withgoabnf.ParseForest, whose SPPF construction is cubic. In #1028 a valid 4 KiB label value took 15–17 s to decode, which blocks any scrape far longer than its 10 s timeout.The upstream fix is pandatix/go-abnf#277, tagged v0.5.5: a lookahead that avoids the useless parse paths.
go.modstill pinned v0.5.3, so the decoder did not get it.Benchmark
BenchmarkLongLine1028(4 KiB label value,-benchtime=1x, linux/amd64, Go 1.26.10):≈236× faster. The remaining cost is still the ABNF forest, but a 4 KiB line no longer blows a scrape timeout. The linear-parser direction discussed in #1028 is still open if you want to go further.
Checks
go test ./...passes (all packages).go.modandgo.sumchange (one require line plus the two sum lines).Ref #1028