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

Performance degradation in SpEL expression evaluation [SPR-16942] #21481

Closed
spring-projects-issues opened this issue Jun 14, 2018 · 7 comments
Closed
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: superseded An issue that has been superseded by another type: bug A general bug

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 14, 2018

Kanthi Vaidya opened SPR-16942 and commented

We are planning to move from Spring 4.3.6 to Spring 5. We noticed a considerable dip in performance. About 50% degradation.

#21421 talks about a specific hot spot. Please look at attached benchmarks in that JIRA.

 

 

Juergen, I saw your code changes for caching the SortedMethods. We don't benefit much if you don't make your ConcurrentHashMap of sorted methods  a static variable.

Even after making the ConcurrentHashMap a static variable, we still don't get back the original performance of the prior spring versions. It definitely helps of course.

This is just one hotspot. More benchmarking and profiling is needed to identify other hot spots. And it probably makes sense to add a test case to the CI infrastructure to catch any such degradations.

This performance degradation, is preventing us from migration to Spring 5.

 


Affects: 5.0.7

Issue Links:

0 votes, 5 watchers

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jun 21, 2018

Christoph Dreis commented

Hi, I noticed this as well recently. The caching solution in #21421 helps only in situations were the ReflectivePropertyAccessor and/or EvaluationContext is not created over and over again. Spring Security`s WebExpressionVoter or more specifically AbstractSecurityExpressionHandler is creating a StandardEvaluationContext with a fresh ReflectivePropertyAccessor every time for example and thus not benefitting much of the cache.

I therefore wonder if we should additionally look at the call-sites and enhance them if possible - similar to what the framework does in some of the annotation relevant code in order to prevent the costly checks in AnnotationUtils or AnnotatedElementUtils.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jul 31, 2018

Juergen Hoeller commented

Christoph Dreis, it is definitely recommended to reuse EvaluationContext instances as far as possible, preferring the use of Expression.getValue with a root object argument over a context-bound root object if necessary. SimpleEvaluationContext (#21130) strongly suggests this usage model on a recent note. And for our internal use of StandardEvaluationContext, we follow the same guideline: see e.g. the expression context caching in StandardBeanExpressionResolver.

So please report any such obvious cases to the corresponding projects if they are not aware of it already.

@spring-projects-issues
Copy link
Collaborator Author

Christoph Dreis commented

I figured already - hence the comment. See it as an addendum to the work that might be done in the Framework itself, which I think is still necessary. But I believe the projects that make use of it are able to optimize the calls themselves as well. I'll let you know once I created the issue(s) in the respective projects.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.x Backlog milestone Jan 11, 2019
@hradilf
Copy link

hradilf commented Jun 21, 2019

Hi @spring-issuemaster,
please, is there any estimation when this issue will be solved?
Thank you.

@hradilf
Copy link

hradilf commented Jan 10, 2020

@spring-issuemaster Any update please? Thanks.

@jhoeller jhoeller changed the title Performance degradation in SPEL expression evaluation [SPR-16942] Performance degradation in SpEL expression evaluation [SPR-16942] Dec 23, 2023
@snicoll
Copy link
Member

snicoll commented Jan 8, 2024

With #31617 being implemented now, we no longer see this issue as actionable. Please give Spring Framework 6.1.x a try. If you're still experiencing performance issue, a new issue with additional details is more than welcome. Thanks!

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2024
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Jan 8, 2024
@snicoll snicoll removed this from the 6.x Backlog milestone Jan 8, 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: superseded An issue that has been superseded by another type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants