Skip to content

Optimize meter Id tag storage#125

Draft
fvallenilla wants to merge 1 commit intopr/line-protocol-builderfrom
pr/id-tagpairs
Draft

Optimize meter Id tag storage#125
fvallenilla wants to merge 1 commit intopr/line-protocol-builderfrom
pr/id-tagpairs

Conversation

@fvallenilla
Copy link
Copy Markdown
Contributor

@fvallenilla fvallenilla commented Mar 26, 2026

Summary

  • store Id tags as ordered pairs instead of copying maps through each clone path
  • keep the line-protocol and builder changes from the base PR and make WithTag/WithTags cheaper on top
  • add focused Id tests for clone, upsert, sorted, and toMap behavior

Benchmark results

Baseline: #124

name                           old time/op    new time/op    delta
CounterAddCombined-12            492.8ns       398.2ns      -19.21%
CounterAddCombinedPostGC-12      586.8ns       487.9ns      -16.84%
geomean                          537.7ns       440.8ns      -18.03%

name                           old B/op       new B/op      delta
CounterAddCombined-12             768.0         608.0       -20.83%
CounterAddCombinedPostGC-12       769.0         609.0       -20.81%
geomean                           768.5         608.5       -20.82%

name                           old allocs/op  new allocs/op delta
CounterAddCombined-12              5.000         4.000      -20.00%
CounterAddCombinedPostGC-12        5.000         4.000      -20.00%
geomean                             5.000         4.000      -20.00%

Test plan

  • go test ./spectator/meter
  • go test ./spectator/meter -run '^$' -bench 'BenchmarkCounterAddCombined$|BenchmarkCounterAddCombinedPostGC$' -benchmem -count=10

Made with Cursor

Store Id tags as ordered pairs so repeated Id construction and cloning do less work while preserving the line-protocol and builder improvements from the base branch.

Made-with: Cursor
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.

1 participant