Skip to content

HDDS-16278. Reuse DecimalFormat in SCMNodeManager statistics - #11113

Open
rich7420 wants to merge 1 commit into
apache:masterfrom
rich7420:HDDS-16278
Open

HDDS-16278. Reuse DecimalFormat in SCMNodeManager statistics#11113
rich7420 wants to merge 1 commit into
apache:masterfrom
rich7420:HDDS-16278

Conversation

@rich7420

@rich7420 rich7420 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

SCMNodeManager built a DecimalFormat per datanode inside the node-stats/JMX loops (convertUnit, calculateStoragePercentage, nodeUsageStatistics). This caches one per thread (ThreadLocal, since DecimalFormat is not thread-safe) for each of the two patterns (#0.0, #0.00). Same pattern and rounding mode, so the formatted output is unchanged.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-16278

How was this patch tested?

https://github.com/rich7420/ozone/actions/runs/32855331989

JMH (out of tree, isolating the formatter acquisition), JDK 21:

pattern ns/op (old -> new) B/op (old -> new)
#0.0 396 -> 147 (-63%) 1064 -> 160
#0.00 375 -> 134 (-64%) 952 -> 160

convertUnit, calculateStoragePercentage and nodeUsageStatistics built a
DecimalFormat per datanode inside the node-stats/JMX loops. Cache one per
thread (ThreadLocal, since DecimalFormat is not thread-safe) for each of the
two patterns (#0.0, #0.00). Same pattern and rounding mode, so the formatted
output is unchanged.
Copilot AI lite review requested due to automatic review settings August 25, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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