Skip to content

Conversation

stsypanov
Copy link
Contributor

Hello, while profiling workload that creates lots of projections I've found out that about 33% of ProxyFactory.getProxy() are taken by JdkDynamicAopProxy.findDefinedEqualsAndHashCodeMethods, see attachment:

The hot spot is here:

@Override
public Object getProxy(@Nullable ClassLoader classLoader) {
	if (logger.isTraceEnabled()) {
		logger.trace("Creating JDK dynamic proxy: " + this.advised.getTargetSource());
	}
	Class<?>[] proxiedInterfaces = AopProxyUtils.completeProxiedInterfaces(this.advised, true);
	findDefinedEqualsAndHashCodeMethods(proxiedInterfaces);
	return Proxy.newProxyInstance(classLoader, proxiedInterfaces, this);
}

It looks like we don't need to call either JdkDynamicAopProxy.findDefinedEqualsAndHashCodeMethods, or AopProxyUtils.completeProxiedInterfaces() at each invocation of JdkDynamicAopProxy.getProxy, because their results don't depend on ClassLoader argument and can be calculated only once at obejct construction time, also advised field is declared final.

Also related methods of ReflectionUtils could also be trivially improved.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 28, 2020
@jhoeller jhoeller self-assigned this Aug 30, 2020
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 30, 2020
@jhoeller jhoeller added this to the 5.3 RC1 milestone Aug 30, 2020
@jhoeller jhoeller merged commit a033660 into spring-projects:master Aug 30, 2020
@stsypanov stsypanov deleted the aop-jdk branch August 30, 2020 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants