-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Reduce garbage from allocations in DeprecationLogger #38780
Conversation
1. Setting length for formatWarning String to avoid AbstractStringBuilder.ensureCapacityInternal calls 2. Adding extra check for parameter array length == 0 to avoid unnecessarily creating StringBuilder in LoggerMessageFormat.format Relates to elastic#37530 Relates to elastic#37411
Pinging @elastic/es-core-infra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left two nits but the actual changes look fine to me. Can you please also:
- Update the PR title so it better reflects the purpose of the change, e.g. "Reduce garbage in deprecation logger" gives readers a much better understanding what this change is about than a more generic title.
- Update the PR description to indicate how much we gain from that?
@@ -259,7 +259,12 @@ public Void run() { | |||
* @return a warning value formatted according to RFC 7234 | |||
*/ | |||
public static String formatWarning(final String s) { | |||
return WARNING_PREFIX + " " + "\"" + escapeAndEncode(s) + "\""; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove empty line.
@@ -40,7 +40,7 @@ public static String format(final String prefix, final String messagePattern, fi | |||
if (messagePattern == null) { | |||
return null; | |||
} | |||
if (argArray == null) { | |||
if ((argArray == null) || (argArray.length == 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove redundant parentheses.
@danielmitterdorfer Thank you for the review! |
1. Setting length for formatWarning String to avoid AbstractStringBuilder.ensureCapacityInternal calls 2. Adding extra check for parameter array length == 0 to avoid unnecessarily creating StringBuilder in LoggerMessageFormat.format Helps to narrow the performance gap in throughout for geonames benchmark (elastic#37411) by 3%. For more details: elastic#37530 (comment) Relates to elastic#37530 Relates to elastic#37411 Relates to elastic#35754
1. Setting length for formatWarning String to avoid AbstractStringBuilder.ensureCapacityInternal calls 2. Adding extra check for parameter array length == 0 to avoid unnecessarily creating StringBuilder in LoggerMessageFormat.format Helps to narrow the performance gap in throughout for geonames benchmark (#37411) by 3%. For more details: #37530 (comment) Relates to #37530 Relates to #37411 Relates to #35754
Helps to narrow the performance gap in throughout for geonames benchmark (#37411) by 3%. For more details: #37530 (comment)
Relates to #37530
Relates to #37411
Relates to #35754