Skip to content

Instantly share code, notes, and snippets.

@cherniag
Created February 23, 2017 13:17
Show Gist options
  • Save cherniag/ace4317d169f0b3db6265575bd08a0e7 to your computer and use it in GitHub Desktop.
Save cherniag/ace4317d169f0b3db6265575bd08a0e7 to your computer and use it in GitHub Desktop.
Spring core performance
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