Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CASSANDRA-20250][trunk] Optimize Counter, Meter and Histogram metrics using thread local counters #3927

Open
wants to merge 25 commits into
base: trunk
Choose a base branch
from

Conversation

netudima
Copy link
Contributor

Optimize Counter, Meter and Histogram metrics using thread local counters

Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20250

Dmitry Konstantinov added 21 commits February 6, 2025 00:37
…sibility

add a basic JMH test
make ThreadLocalMetricsTest parametrized
add JMH for Meter implementations
switch to approximate clock to reduce time retrieval overhead
…onentialMovingAverages, use single uncounted value for all 3 rates
move tickIfNessesary out from Meter.mark logic to a periodic background task
remove LazySetArrayThreadLocalMetrics implementation, rename PiggybackArrayThreadLocalMetrics to ThreadLocalMetrics
use atomic long for hints in-procress counter which is frequently read
introduce common Destroyable interface for metrics
move cleanDeadAndUpdateSummaries invocations to a background thread and metric creation/destoying logic
…lity

move ThreadLocalExponentialMovingAverages logic to ThreadLocalMeter itself
…ments, so we have to keep tick values per instance

Fix condition in allocateRateGroupOffset
Add dynamic Meter creation/destroying emulation
…jects associated with dead threads

use BitSet for free metric id set

Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20251
…ed to metrics and threads lifecycles

Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20251
Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20251
Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20251
Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20251
Copy link
Contributor

@clohfink clohfink left a comment

Choose a reason for hiding this comment

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

Wouldn’t using longadder instead of atomic longs do the same thing without having to create a layer over everything?

@netudima
Copy link
Contributor Author

netudima commented Feb 24, 2025

unfortunately no, it is already LongAdder used in Dropwizard but it is not for free from CPU usage for our amount of metrics + it has a high memory overhead: CASSANDRA-20250 - here there is a long conversation with Benedict about it and different perf test results.

@netudima
Copy link
Contributor Author

A similar idea is also described by Nitsan: https://psy-lob-saw.blogspot.com/2013/06/java-concurrent-counters-by-numbers.html (as ThreadLocalCounter option)

Dmitry Konstantinov added 4 commits March 2, 2025 18:55
… backward compatibility for Dropwizard MetricRegistryListener and Reporter functionality.

Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20250
Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20250
Fix concurrency issues in writing from multiple threads to ThreadLocalMeter.rates

Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20250
…ent class field separately

Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-20250
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.

2 participants