Spring-expression performance regression due to missing annotations on Context variables classes #33948
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
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 injava.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
The text was updated successfully, but these errors were encountered: