Open jdmcclur opened 4 months ago
https://github.com/unbescape/unbescape/blob/master/src/main/java/org/unbescape/html/HtmlEscapeSymbols.java does show a fair amount of initialization of static variables, including some calls inside a static code block. The problem is that we don't JIT compile <clinit>
methods (or maybe even anything when a <clinit>
is on the stack) since they are only expected to be invoked once, so this non-trivial logic runs interpreted, i.e. 10 times slower than it could if it were JITed
and
are the calls inside the static code block in that <clinit>
and are clearly quite a bit heavier than a typical <clinit>
would be expected to be (many Java statements).
I will need to think about whether something can be done in the JVM at checkpoint time for handling this better, but the problem will be to identify why this code is even of interest at all at that time, if it only runs as part of handling the first request.
Thinking also of what you could even attempt in Liberty, a couple of options (not sure how practical)
Class.forName
on them all before checkpoint. This would increase memory footprint before checkpoint, but we may be able to work around that if it led to decent startup improvement (we need to check if this is even practical).
Overall Springboot performance is looking really good with InstantOn, but always working to make things better. Running with Pet Clinic there seems to be a decent amount of overhead with initializing ThymeLeaf.
Most of the time is spent in org/thymeleaf/engine/TemplateManager.parseAndProcess, eventually initializing
org/unbescape/html/HtmlEscapeSymbols
Before that, a lot of time is spent in getConfiguration where a lot gets initialized on the first request.
StackTrace
I did successfully load/initialize org/unbescape/html/HtmlEscapeSymbols here, but that seem pretty hacky. https://github.com/OpenLiberty/open-liberty/blob/3d4a37a15effdd14b118355ad5181df4c4ddaf52/dev/com.ibm.ws.app.manager.springboot/src/com/ibm/ws/app/manager/springboot/internal/SpringBootApplicationImpl.java#L898