Remix.run Logo
bluGill 3 hours ago

If low latency is your goal than you don't want JIT. JIT has two issues in low latency, first the first time through your code isn't compiled yet and so you get high latency. Second, it optimizes for the common case, which means when you hit an exception that exception will be higher latency because everything hits a branch miss.

Of course we are talking generals here. Sometimes the above is acceptable and Java/JIT is just fine. Sometimes it is unacceptable and you cannot use Java/JIT. Know your domain.

Of course in all cases (C, Rust, C++), you have to understand the system and what it is doing. Every language has a standard library that will do things that are not low latency on you. You have to know which library functions will do what, memory allocation and copies are both things that code often does without thought that are incompatible with low latency. No matter what you need to know what your language does that is against you.

pretzellogician 2 hours ago | parent | next [-]

Valid points, but this doesn't mean JIT doesn't work for relatively lower-latency coding.

To avoid the compilation etc. hit, common practice is to do some "warmups" before serving users. (Another reply has other ways to avoid this hit.)

Handling exceptions is higher latency, but they can/should be optimized out, so you're not hitting exceptions as part of your standard workflow (or even your 1% workflow).

re-thc 3 hours ago | parent | prev [-]

> If low latency is your goal than you don't want JIT. JIT has two issues in low latency...

There's startup "AOT cache" via Leyden that speeds up startup. Isn't native speed up it's quite a big boost.

Then there's GraalVM that does give you a native image. Real AOT.