Skip to content

MINOR Metrics: use String.intern() to reduce duplicate metric names and tags #20328

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

stevenschlansker
Copy link
Contributor

@stevenschlansker stevenschlansker commented Aug 8, 2025

While diagnosing an out of memory condition, our profiler alerted us
that tens of megabytes of our heap was used to store redundant String
objects.

In particular, the strings thread_id, rocksdb_state_id, task_id,
and org.apache.kafka.consumer.fetch.manager.preferred.read.replica
alone take 12MB. All of these objects are strongly held by MetricKey or
MetricName instances.

Interning a string is a somewhat expensive operation, however, metric
names are generally created once at initialization and then not again
dynamically (excepting some per-connection tracking)

@github-actions github-actions bot added triage PRs from the community clients small Small PRs labels Aug 8, 2025
@stevenschlansker stevenschlansker changed the title Metrics: use String.intern() to reduce duplicate metric names and tags MINOR Metrics: use String.intern() to reduce duplicate metric names and tags Aug 8, 2025
…nd tags

While diagnosing an out of memory condition, our profiler alerted us that
tens of megabytes of our heap was used to store redundant String objects.

In particular, the strings `thread_id`, `rocksdb_state_id`, `task_id`, and
`org.apache.kafka.consumer.fetch.manager.preferred.read.replica` alone take 12MB.
All of these objects are strongly held by MetricKey or MetricName instances.

Interning a string is a somewhat expensive operation, however, metric names are generally
created once at initialization and then not again dynamically (excepting some per-connection tracking)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clients small Small PRs triage PRs from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant