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

CglibAopProxy: Skip non-overridden methods of Object.class as those which for sure have no advice #24649

Closed

Conversation

stsypanov
Copy link
Contributor

Currently in case of frozen AOP chain CglibAopProxy creates fixed callbacks for all methods of the target class, while in many cases only a couple of them actually need to have advices. Other methods like native ones of java.lang.Object and others non-overridden can be skipped saving some time and memory without breaking functionality.

I've used a benchmark measuring costs of creating a prototype bean with one aspected method and got those results:

before

Benchmark                                                             Mode  Cnt      Score     Error   Units
AspectPrototypeBenchmark.getAdvisedBean                               avgt  100     14.024 ±   0.164   us/op
AspectPrototypeBenchmark.getAdvisedBean:·gc.alloc.rate                avgt  100    498.209 ±   4.753  MB/sec
AspectPrototypeBenchmark.getAdvisedBean:·gc.alloc.rate.norm           avgt  100  10983.307 ±  14.193    B/op
AspectPrototypeBenchmark.getAdvisedBean:·gc.churn.G1_Eden_Space       avgt  100    498.314 ±  22.655  MB/sec
AspectPrototypeBenchmark.getAdvisedBean:·gc.churn.G1_Eden_Space.norm  avgt  100  10992.978 ± 505.995    B/op
AspectPrototypeBenchmark.getAdvisedBean:·gc.churn.G1_Old_Gen          avgt  100      0.001 ±   0.001  MB/sec
AspectPrototypeBenchmark.getAdvisedBean:·gc.churn.G1_Old_Gen.norm     avgt  100      0.025 ±   0.010    B/op
AspectPrototypeBenchmark.getAdvisedBean:·gc.count                     avgt  100    327.000            counts
AspectPrototypeBenchmark.getAdvisedBean:·gc.time                      avgt  100    357.000                ms

after

Benchmark                                                             Mode  Cnt     Score     Error   Units
AspectPrototypeBenchmark.getAdvisedBean                               avgt  100     8.150 ±   0.202   us/op
AspectPrototypeBenchmark.getAdvisedBean:·gc.alloc.rate                avgt  100   558.719 ±  11.480  MB/sec
AspectPrototypeBenchmark.getAdvisedBean:·gc.alloc.rate.norm           avgt  100  7133.664 ±   5.594    B/op
AspectPrototypeBenchmark.getAdvisedBean:·gc.churn.G1_Eden_Space       avgt  100   560.401 ±  26.718  MB/sec
AspectPrototypeBenchmark.getAdvisedBean:·gc.churn.G1_Eden_Space.norm  avgt  100  7159.093 ± 316.966    B/op
AspectPrototypeBenchmark.getAdvisedBean:·gc.churn.G1_Old_Gen          avgt  100     0.001 ±   0.001  MB/sec
AspectPrototypeBenchmark.getAdvisedBean:·gc.churn.G1_Old_Gen.norm     avgt  100     0.012 ±   0.005    B/op
AspectPrototypeBenchmark.getAdvisedBean:·gc.count                     avgt  100   330.000            counts
AspectPrototypeBenchmark.getAdvisedBean:·gc.time                      avgt  100   412.000                ms

…ave no advice and other performance improvements
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 5, 2020
@sbrannen sbrannen requested a review from jhoeller March 6, 2020 11:38
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Mar 6, 2020
@snicoll snicoll removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 24, 2023
@snicoll snicoll self-assigned this Aug 24, 2023
@snicoll snicoll added this to the 6.1.0-RC1 milestone Aug 24, 2023
snicoll pushed a commit that referenced this pull request Aug 24, 2023
snicoll added a commit that referenced this pull request Aug 24, 2023
@snicoll snicoll closed this in 2a37284 Aug 24, 2023
@stsypanov stsypanov deleted the cglib-aop-proxy-improvement branch August 24, 2023 10:38
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.

None yet

4 participants