NickJavaDev88 opened a new pull request, #11131:
URL: https://github.com/apache/ozone/pull/11131

   ## What changes were proposed in this pull request?
   
   Guava's `Preconditions.checkState(boolean, String)` evaluates its message 
argument before the call, so the error string is built via `StringBuilder` 
concatenation on every invocation even when the check passes. Two of these sit 
on hot paths:
   
   * `XceiverClientRatis.watchForCommit` runs the check on every commit-watch 
reply (`"Returned index " + updated + " < expected " + index`).
   * `ReferenceCounted.decrementRefCount` runs it on every snapshot reference 
release (`"This thread " + tid + " already have a reference count of zero."`).
   
   Each successful check allocates a `StringBuilder`, its backing `char[]` and 
the resulting `String`, all short-lived garbage that only adds young-gen GC 
pressure.
   
   This PR switches both call sites to Guava's template form 
(`checkState(condition, "... %s ... %s", arg1, arg2)`). Guava resolves these to 
its primitive `long` overloads (`checkState(boolean, String, long, long)` and 
`checkState(boolean, String, long)`), so no boxing or `Object[]` allocation 
occurs, and the message is only formatted when the check fails. The failure 
messages are unchanged.
   
   This is a sub-task of HDDS-16276.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-16280
   
   ## How was this patch tested?
   
   No functional change, so no new tests were added:
   
   * Behavior is unchanged — the assertions and their failure messages are 
identical.
   * Overload resolution to the primitive `long` variants is compiler-verified 
(confirmed against Guava 33.6.0 sources; JLS most-specific applicable method).
   * The change only removes allocations on the passing path.
   
   Verified locally:
   
   * `mvn compile -pl :hdds-client,:ozone-manager -am -DskipShade -DskipRecon 
-DskipDocs` -> BUILD SUCCESS
   * `./hadoop-ozone/dev-support/checks/checkstyle.sh` -> 0 violations
   
   CI on the fork will run the full unit and integration suites.
   
   Generated-by: Claude Code (Claude Sonnet 5) - PR description only
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to