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 looking up annotation types during type matching #5906

Merged
merged 1 commit into from
May 12, 2022

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Apr 21, 2022

Part of #5791
Like jdk, byte-buddy getDeclaredAnnotations does not report annotations whose class is missing. To do this it needs to locate the bytes for annotation types used in class. Which means that if we have a matcher that matches methods annotated with @Foo byte-buddy will end up location bytes for all annotations used on any method in the classes that this matcher is applied to. From our perspective this is unreasonable, we just want to match based on annotation name with as little overhead as possible. As we match only based on annotation name we never need to locate the bytes for the annotation type.
Implementation is a bit of a hack, so we'll have to consider whether we want to do this at all.

@laurit laurit requested a review from a team April 21, 2022 19:11
@laurit laurit force-pushed the lazy-annotations branch from ff69e5f to 32db360 Compare May 11, 2022 13:38
Comment on lines +519 to +524
enterLoadAnnotations();
try {
return method.getDeclaredAnnotations();
} finally {
exitLoadAnnotations();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@trask you asked how big of a difference this makes. Calling method.getDeclaredAnnotations() without enterLoadAnnotations produced count=541790, time=1290ms and with enterLoadAnnotations count=541715, time=87ms when starting liferay.

@trask trask merged commit 8865ab6 into open-telemetry:main May 12, 2022
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
@laurit laurit deleted the lazy-annotations branch July 6, 2023 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants