Hi devs,
I've been finding that Jetty takes a lot of time to start lately. So I've run some
profiling on it.
Starting Jetty (till the STARTING message) takes 15 seconds on my machine (in debug mode,
we win 3 seconds, ie 12s start time), split like this:
* 50% of the time spent scanning jars in WEB-INF/lib (JarInputStream.getNextJar()) - 7s
* 10% in Jetty itself - 2s
* 40% in our code in Extension Manager init (2.5s) and in Component registration from
their annotations (2.5s) - 5s
If I remove the start of the EM in XWikiServletContextListener, we start in 7 seconds
(instead of 15s)
If I try to start Jetty without any webapp, it starts in 500ms.
If I remove the oldcore legacy jar (2.5MB) we win 1 second in start up time.
Note: This is all before XWiki.init() is called on the first request.
Analysis of ComponentAnnotationLoader (2.5s):
* 1.2s just loading classes from the CL
* 1s getDeclaredFields (reflection API)
* 800ms initializing SLF4J
Analysis of Extension Manager init (2.5s):
* In DefaultCoreExtensionScanner.loadExtensions():
** 500ms URL.toURI()
** 500ms MavenXpp3Reader.read() - POM reading
** 150ms org.Reflections scanning
** 150ms resource loading from CL (getResourceAsStream())
* In DefaultExtensionLicenseManager.initialize()
** 314ms in org.Reflections
* 130ms of loading xwiki.properties
Conclusion
=========
* XWiki's size in number of JARs and their sizes makes it long to start Jetty.
* We could make some small optimizations in EM and Component loading but we wouldn't
win that much, on the order of 2s in total (i.e. 15% of total load time)
Thanks
-Vincent