Skip to content

Benchmark json-iter, stdlib json and json/v2 - #2107

Merged
bwplotka merged 1 commit into
prometheus:mainfrom
liggitt:benchjsonv2
Sep 9, 2026
Merged

Benchmark json-iter, stdlib json and json/v2#2107
bwplotka merged 1 commit into
prometheus:mainfrom
liggitt:benchjsonv2

Conversation

@liggitt

@liggitt liggitt commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Conditionally benchmarks Go 1.27 stdlib json/v2 when run with Go 1.27 (skips json/v2 when not run on Go 1.27). Part of gathering test data for #2105

Reformats the benchmark names to group what is being tested with the different encoder/decoder as the last test name segment

Best reviewed ignoring whitespace - https://github.com/prometheus/client_golang/pull/2107/changes?w=1

cc @bwplotka

@liggitt
liggitt force-pushed the benchjsonv2 branch 3 times, most recently from 3470a99 to dd08f42 Compare September 8, 2026 16:55
Signed-off-by: Jordan Liggitt <liggitt@google.com>

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Some nits, but can be done later across our benchmarks

Comment thread api/prometheus/v1/api_bench_test.go

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on the nits with @bwplotka

Otherwise LGTM

@bwplotka
bwplotka merged commit 1621a2c into prometheus:main Sep 9, 2026
15 checks passed
radianceded added a commit to radianceded/client_golang that referenced this pull request Sep 10, 2026
- migrate sequential benchmarks from 'for i := 0; i < b.N; i++' to
  b.Loop, dropping the now-automatic timer management (ResetTimer /
  StopTimer around setup);
- benchmarks that fan work out to goroutines sized by b.N
  (benchmarkHistogramObserve/Write, benchmarkSummaryObserve/Write,
  BenchmarkCounterWithLabelValuesConcurrent) and b.RunParallel
  (BenchmarkParallelCounter) keep their b.N form, which Loop does not
  cover;
- vec_test's WithLabelValues permutation loop keeps its input rotation
  via an explicit counter, since Loop does not expose an index;
- normalize b.Run case names to key=value so benchstat can project on
  them: series=/dp=/op=/type=/encoder= in the v1 API benchmarks,
  size= in the API client, op=/size= in promhttp, and labels=/constraint=
  in the counter vec table (following prometheus#2107).

Fixes prometheus#2113

Signed-off-by: lr <2644847367@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants