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

Remove costly matchers from ignore list #1233

Merged
merged 2 commits into from
Feb 21, 2020
Merged

Conversation

tylerbenson
Copy link
Contributor

Removing these matchers caused the time spent matching ignores in my sample app to go from greater than 1 second to less than 100 ms.

@tylerbenson tylerbenson requested a review from a team as a code owner February 19, 2020 22:58
@tylerbenson tylerbenson added the tag: performance Performance related changes label Feb 19, 2020
Removing these matchers caused the time spent matching ignores to go from greater than 1 second to less than 100 ms.
// Unlikely to ever need to instrument an annotation:
.or(ElementMatchers.<TypeDescription>isAnnotation())
// Unlikely to ever need to instrument an enum:
.or(ElementMatchers.<TypeDescription>isEnum())
Copy link
Contributor

Choose a reason for hiding this comment

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

It is really-really surprising that these are slow - by the looks is it they should just be doing an & on two ints.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it is a bit counter intuitive, but I think understand why.

My suspicion is that name checks don't actually require materializing the TypeDescription from the underlying class file, since the name is known ahead of time.

On the other hand, the enum & annotation flag are only present in the class file, so ByteBuddy probably has to load the class file to do the check.

If the TypeDescription were already loaded then I have no doubt that isEnum & isAnnotation would be cheaper than the name check.

@tylerbenson tylerbenson merged commit 6609215 into master Feb 21, 2020
@tylerbenson tylerbenson deleted the tyler/optimize-ignores branch February 21, 2020 01:52
@randomanderson randomanderson added this to the 0.44.0 milestone Feb 26, 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

4 participants