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

Faster type matching #8525

Merged
merged 1 commit into from
Jun 2, 2023
Merged

Conversation

laurit
Copy link
Contributor

@laurit laurit commented May 18, 2023

Figuring out which types need to be transformed is quite costly. Measuring the time spent in

public boolean matches(T target) {
try {
return matcher.matches(target);
} catch (Throwable e) {
logger.log(Level.FINE, description, e);
return false;
}
}

while starting Liferay

LoggingFailSafeMatcher#match count=25981347, time=9796ms

This pr decomposes matchers with reflection and divides them into 3 categories: matches by class name, matches by class name in hierarchy, something else. The 3rd category has about 10 matchers. Transformer list inside byte buddy is replaced with a proxy that when we know that current class isn’t going to match any of the name or hierarchy matchers just returns the matchers from the 3rd category. Because we can get the super type names in defineClass we can quickly tell whether there is a hierarchy matcher that applies to given class.

LoggingFailSafeMatcher#match count=1100249, time=3498ms

@laurit laurit requested a review from a team as a code owner May 18, 2023 09:54
Copy link
Member

@mateuszrzeszutek mateuszrzeszutek left a comment

Choose a reason for hiding this comment

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

👍

@laurit laurit merged commit 81f6a3a into open-telemetry:main Jun 2, 2023
44 checks passed
@laurit laurit deleted the optimize-matchers branch June 2, 2023 15:35
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.

None yet

2 participants