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

Cache byte[] for the last 64 tags #1533

Merged
merged 1 commit into from Jun 4, 2020
Merged

Conversation

bantonsson
Copy link
Contributor

This removes roughly 30% of all byte[] allocations and 70% of all sun.nio.cs.UTF_8$Encoder allocations during a pet-clinic run.

Not sure about the cache size.

@bantonsson bantonsson added the tag: performance Performance related changes label Jun 4, 2020
@bantonsson bantonsson self-assigned this Jun 4, 2020
Copy link
Member

@richardstartin richardstartin left a comment

Choose a reason for hiding this comment

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

I agree, configuration would be good.

@bantonsson bantonsson marked this pull request as ready for review June 4, 2020 13:37
@bantonsson bantonsson requested a review from a team as a code owner June 4, 2020 13:37
@@ -107,7 +126,21 @@ private static void writeUTF8Tag(final String value, final MessagePacker destina
destination.packRawStringHeader(interned.length);
destination.addPayload(interned);
} else {
destination.packString(value);
byte[] bytes = null;
Copy link
Contributor

@dougqh dougqh Jun 4, 2020

Choose a reason for hiding this comment

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

Oops, I see misunderstood. This is covering the value. Nice.

@bantonsson bantonsson merged commit 313aaf9 into master Jun 4, 2020
@bantonsson bantonsson deleted the bantonsson/pack_string_cache branch June 4, 2020 13:41
@github-actions github-actions bot added this to the 0.54.0 milestone Jun 4, 2020
// Something went wrong. We will write out the string the normal way.
}
}
if (bytes != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When would this ever be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the string is "" or if the tagCache.get throws an exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: performance Performance related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants