I am using Thymeleaf 3.0.8.RELEASE /jboss EAP 6/Java 8.
We are currently doing performance test and often bad response time because of thymeleaf.
We are using Dynatrace to detect code hotspot. We are still at the beginning of our test and load is not really big (50 concurrent users on 6 jboss with loadbalancing).
At IS level, every thing seems fine. The CPU and the memory of the JVM are barely used.
There a lot of time spent in the SpelExpression.compileExpression method. There like 10% of the request that spent more than 300ms up to 1s in that method.
We are using template with a lot of fragment that include fragment as well.
Is there any performance tips related to expression ? Should we avoid some type of expression ?
Please note that compilation of SpEL expressions is performed only the first time. That's the idea of compiling them, in fact. Once these expressions are compiled for the first execution of a page, the results of their compilation are cached and used for any following execution (unless the cache overflows, but its size is configurable).
So I would recommend to repeat your tests including a warmup period for each of your pages, so that you give the compiler (and other cached structures) time to optimize their job.
This said, if your expressions vary too much (maybe they are dynamic) and are almost never reused among executions, you might want to entirely disable the SpEL compilation process, which you can do with a configuration parameter at the SpringStandardDialect instance.
It's not dynamic pages that would be a problem, but expressions themselves. I mean, the fact that the expressions being executed each time for the same page would be different (not their results). This is normally done via preprocessing...