Optimize startup time: cache configuration
dsyer opened this issue · comments
The Pet Clinic depends on EhCache, but it doesn't even use it unless the "production" profile is enabled. And yet it costs a couple hundred ms apparently (see benchmarks at https://github.com/dsyer/spring-boot-startup-bench). This might be just a special case of too much condition processing on startup, but I did notice that all cache types are configured in CacheConfigurationImportSelector
, even if they are switched off by condition processing, and maybe this is unnecessary.
I noticed that too and we should revisit the condition to back-off sooner indeed. If you have an app with nothing particular on the classpath, the cache conditions always shows up which is not nice at all.
Some analysis: spring-attic/spring-init#5. The benchmark code is there as well I think (in the petclinic sample inside that project). See also this Spring Framework issue: spring-projects/spring-framework#22175.