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

Spring-expression performance regression due to missing annotations on Context variables classes #33948

Open
justinas-dabravolskas opened this issue Nov 22, 2024 · 0 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@justinas-dabravolskas
Copy link

Performance degradation with SpEL expressions occurs when the expression context contains objects lacking annotations.

This issue commonly arises when using Guava collections without JSR-305 annotations at runtime.

The root cause is that org.springframework.core.convert.TypeDescriptor attempts to load annotations for all context classes. If annotations are missing, this leads to classpath scanning during each evaluation, significantly impacting performance. The actual impact varies depending on the classpath and concurrent thread count. In a single threaded testing, it resulted in approximately a twofold decrease in speed. The penalty hit increases with concurrency because of synchronization in java.lang.ClassLoader.loadClass. Although SpEL doesn’t inherently require annotations, TypeDescriptor still loads them by default. Perhaps a variant of TypeDescriptor that omits the annotation loading process could be introduced to address this inefficiency.
Screenshot shows profiler output while evaluating against Guava map in a loop.
Using org.springframework:spring-expression:6.1.15
Screenshot 2024-11-22 at 16 48 03

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 22, 2024
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Nov 23, 2024
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) status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

No branches or pull requests

3 participants