Hello, we have noticed a performance issue at OpenMRS startup (version 2.3.0): 13 minutes is sometimes required. I have cleaned and rebuilt our modules, docker,… and checked that lucene indexation is not launched.
I started OpenMRS using the Visual VM profiler and here are some results ( still under investigation). The profiler gives:
With the debugger I found that the error is mainly
Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject
and it’s generating in the method
org.openmrs.module.ModuleUtil#refreshApplicationContext when the Spring Context is refreshed (
org.springframework.context.support.AbstractApplicationContext#refresh) and the errors occurs mainly when
org.springframework.context.support.AbstractApplicationContext#initMessageSource is called.
It seems that ( sorry I won’t be clear here ):
org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator is called when a MessageSource object is created, it’s intercepted by a TransactionInterceptor, … and then we ended with a situation where some objects are created too early in the refresh action.
Here is modification I check: replace the
DefaultAdvisorAutoProxyCreator by a custom
ProxyCreator to skip auto-proxying (
org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator#shouldSkip) for some bean classes (
Thanks to this OpenMRS starts in 7 min.
Currently I don’t know the whole impact of these modifications and if I really on the root cause of the performance issue… Does someone have some feedback ?
Of course, I could propose a PR and create a ticket concerning this point.