Created
February 23, 2017 13:17
-
-
Save cherniag/ace4317d169f0b3db6265575bd08a0e7 to your computer and use it in GitHub Desktop.
Spring core performance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. CachedIntrospectionResults.<init> takes a lot of time. Every BeanWrapper passes from CachedIntrospectionResults.forClass, it inokes | |
(if absent in static cache) Introspector.getBeanInfo which takes a lot of time. Cache usage occurs at | |
AbstractApplicationContext.finishBeanFactoryInitialization in scope of refresh() method but at the end of refresh method in finally block | |
there is call to resetCommonCaches: | |
protected void resetCommonCaches() { | |
ReflectionUtils.clearCache(); | |
ResolvableType.clearCache(); | |
CachedIntrospectionResults.clearClassLoader(getClassLoader()); // <---- remove it | |
} | |
which clears cache and if context is initialized a lot of time (topologies, etc) there is no cache reusage. To fix it: | |
override resetCommonCaches in child context without resetCommonCaches call: | |
protected void resetCommonCaches() { | |
ReflectionUtils.clearCache(); | |
ResolvableType.clearCache(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment