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

Reduce garbage from allocations in DeprecationLogger #38780

Merged
merged 2 commits into from
Feb 22, 2019

Conversation

ebadyano
Copy link
Contributor

@ebadyano ebadyano commented Feb 12, 2019

  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

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
@ebadyano ebadyano added >enhancement :Core/Infra/Logging Log management and logging utilities v8.0.0 v7.2.0 labels Feb 12, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@danielmitterdorfer danielmitterdorfer left a 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) + "\"";

Copy link
Member

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)) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: remove redundant parentheses.

@ebadyano ebadyano changed the title Adding small deprecation logging optimizations Reduce garbage in deprecation logger Feb 22, 2019
@ebadyano ebadyano changed the title Reduce garbage in deprecation logger Reduce garbage from allocations in deprecation logger Feb 22, 2019
@ebadyano ebadyano changed the title Reduce garbage from allocations in deprecation logger Reduce garbage from allocations in DeprecationLogger Feb 22, 2019
@ebadyano ebadyano merged commit 9d54e74 into elastic:master Feb 22, 2019
@ebadyano
Copy link
Contributor Author

@danielmitterdorfer Thank you for the review!

@ebadyano ebadyano deleted the deprecation-logger branch February 22, 2019 20:07
ebadyano added a commit to ebadyano/elasticsearch that referenced this pull request Feb 25, 2019
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
ebadyano added a commit that referenced this pull request Feb 25, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants