Hello! Indulge me for a moment if you will. Completely new to cranelift but decent at rust. I have a DSL that is run in a hot loop that is essentially this:
if a > b:
"apple"
else if c == 23 && name == "jinxit":
"banana"
else if you_get.contains("the idea"):
"lemon"
...
The input DSL is only known at runtime so I would like to compile this (can be "slow") and run it (must be fast). I'm getting a bit lost in the terminology though, what parts of cranelift should I be looking at? JIT to me like it would run slower than AOT, but maybe that's not accurate?
Cranelift is optimized for JIT compilation. It is missing a lot of optimizations for example LLVM has. This means that it can compile fast, but the code runs slower. If you want your code to run as fast as possible you should probably try LLVM. LLVM has a JIT engine too. It just compiles slower than Cranelift.
JITted code doesn't necessarily run slower than AOT compiled code. In fact in case of a JIT some overhead may be avoided in certain cases. The main difference between the two is if you compile it first and then run it at a later time (AOT, ahead of time) or compile it just before you run it (JIT, just in time).
Last updated: Dec 23 2024 at 12:05 UTC