Skip to content

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 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 force-pushed the optimize-matchers branch from d4d4674 to a3f6876 Compare May 29, 2023 15:03
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.

2 participants