casid / jte

Secure and speedy templates for Java and Kotlin.
https://jte.gg
Apache License 2.0
748 stars 56 forks source link

Initial response time is slower on first request than on subsequent requests #306

Closed Jerbell closed 8 months ago

Jerbell commented 8 months ago

Hi, this is more of a query than an issue.

We use KTE templates and the gradle command: jte { generate() }. I notice that the initial requests have a slower reponse time, and I don't think it's to do with our code.

200 GET https://localhost:32327/xxx from 127.0.0.1 in 246ms
200 GET https://localhost:32327/xxx from 127.0.0.1 in 15ms

and

200 GET https://localhost:32327/yyy from 127.0.0.1 in 43ms
200 GET https://localhost:32327/yyy from 127.0.0.1 in 8m

Is this something you notice & expected behaviour, or something on our end?

TIA!

casid commented 8 months ago

Hi @Jerbell,

this is expected behavior, since the class loader needs to load the generated classes on the first request. Probably at some point the JIT will kick in and make everything faster too.

Cheers

Jerbell commented 8 months ago

Thanks for the explanation - all good :)