Skip to content

counter: cache entries for saved positional-label children - #865

Open
SidheshwarSarangal wants to merge 1 commit into
prometheus:mainfrom
SidheshwarSarangal:contributor/cached-counter-child
Open

SidheshwarSarangal wants to merge 1 commit into
prometheus:mainfrom
SidheshwarSarangal:contributor/cached-counter-child

Conversation

@SidheshwarSarangal

Copy link
Copy Markdown

Saved counter children currently validate labels and rebuild the storage key on every increment. Cache the entry for positional string/number labels, invalidating it after reset() or remove().

Object-form labels and exemplar-enabled counters retain their existing paths. Add lifecycle tests and comparison benchmarks.

Relates to #863.

Validation

  • npm test -- --runInBand: 31 suites, 671 tests, and 34 snapshots passed.
  • Node.js v24.22.0, Linux x64, Intel Core 5 210H.
  • Nine alternating benchmark rounds, 1,000,000 increments per round:
Labels Saved child before After Speedup
0 35.11 ns/op 12.06 ns/op 2.91×
1 85.38 ns/op 12.06 ns/op 7.08×
3 312.62 ns/op 11.94 ns/op 26.18×

Direct increments varied by approximately 2% in this run.

AI assistance was used to prepare the implementation, tests, and benchmark helper.

@jdmarshall, could you review whether this scope fits the direction of #863?

Invalidate cached entries after reset or removal. Preserve object-label and exemplar behavior, and add lifecycle tests and benchmarks.

Relates to prometheus#863

Signed-off-by: Sidheshwar Sarangal <sidheshwar.sarangal@gmail.com>

This branch has not been deployed

No deployments
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