Optimize SystemEnvironmentPropertyMapper.isLegacyAncestorOf #44808
Labels
for: external-project
For an external project and not something we can fix
status: superseded
An issue that has been superseded by another
demo.zip
are checking the performance impact of adding Consumer beans with spring-cloud-function.
We added 100 Consumer beans and configured them in
spring.cloud.function.definition
and underspring.cloud.stream.function.bindings
.We see that the initialization time of the
BindingServiceProperties
bean increased from 59 milliseconds for a single topic to 5581 milliseconds for 100 topics.We profiled the application using JProfiler.
We see the top hotspot in:
org.springframework.boot.context.properties.source.ConfigurationPropertyName$ElementsParser.parse
Most calls are coming from:
org.springframework.boot.context.properties.source.SystemEnvironmentPropertyMapper.isLegacyAncestorOf
Debugging it, we see that
isLegacyAncestorOf
is called many times for the same name (each time with a different candidate).But
buildLegacyCompatibleName
depends only on the name, not on the candidate it checks against.Since
buildLegacyCompatibleName
is relatively time-consuming, we think it makes sense to cache it per input name for optimization.Or possibly, some caching can help at a higher level in the call stack of
Binder.bindObject
(see the stacktrace below).Attaching a demo application that shows this behavior on startup.
Thanks, Avner.
Stacktrace
The text was updated successfully, but these errors were encountered: