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

avoid creating new strings prior to jar lookup #1580

Merged
merged 2 commits into from
Jun 12, 2020

Conversation

richardstartin
Copy link
Member

Uses the name we will lookup by as the key in the HashMap during building, which has two effects:

  1. Don't need to allocate - this explains some of the unreferenced strings I found in a heap dump taken with EpsilonGC
  2. Might not need to compute the hash code during the lookup

I don't think this changes behaviour, but I'm not entirely sure.

@richardstartin richardstartin requested a review from a team as a code owner June 12, 2020 13:02
Copy link
Contributor

@bantonsson bantonsson left a comment

Choose a reason for hiding this comment

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

Can't see that this would change behavior, since these are the only places that filenameToEntry is used.

@richardstartin
Copy link
Member Author

richardstartin commented Jun 12, 2020

Well, when we shadow, we replace ".class" with ".classdata" and it's not entirely clear to me that the map can only contain our classes. If we take someone else's class and suffix it with "data" prior to lookup and the map contains classes which aren't ours, it would previously miss, but would hit now. Hence the ambivalence despite the obvious benefits.

@richardstartin
Copy link
Member Author

I did a small test with pet clinic where the process exits once the agent is installed to check this didn't have negative consequences. On master:

5.40s user 0.31s system 267% cpu 2.135 total
5.03s user 0.24s system 293% cpu 1.796 total
5.03s user 0.26s system 291% cpu 1.816 total

On this branch:

4.76s user 0.25s system 298% cpu 1.677 total
4.77s user 0.25s system 285% cpu 1.756 total
4.60s user 0.23s system 290% cpu 1.660 total

Take it with a pinch of salt, but this doesn't make things worse for the sake of reduced allocation.

Copy link
Contributor

@randomanderson randomanderson left a comment

Choose a reason for hiding this comment

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

While I think it's unlikely, you're right that there could be other items in the jar that end with "data". The easy fix is to check if the suffix is .classdata instead

…strap/InternalJarURLHandler.java

Co-authored-by: Laplie Anderson <randomanderson@users.noreply.github.com>
@richardstartin richardstartin added the tag: performance Performance related changes label Jun 12, 2020
@richardstartin richardstartin merged commit 2f36d6f into master Jun 12, 2020
@richardstartin richardstartin deleted the richardstartin/url-lookup branch June 12, 2020 15:39
@github-actions github-actions bot added this to the 0.55.0 milestone Jun 12, 2020
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

3 participants