I recently discovered that one can use JIT (just in time) compilation with R using the compiler package (I summarizes my findings on this topic in a recent blog post).
One of the questions I was asked is:
Is there any pitfall? it sounds too good to be true, just put one line of code and that's it.
After looking around I could find one possible issue having to do with the "start up" time for the JIT. But is there any other issue to be careful about when using JIT?
I guess that there will be some limitation having to do with R's environments architecture, but I can not think of a simple illustration of the problem off the top of my head, any suggestions or red flags will be of great help?
The compiler is implemented almost entirely in R, with just a few support routines in C to manage compiled code objects. From the perspective of using JIT with R, the above means that the {compiler} package does not offer a jit compiler to a machine code, but it does offer it in order to turn it into byte code.
A JIT compiler can be faster because the machine code is being generated on the exact machine that it will also execute on. This means that the JIT has the best possible information available to it to emit optimized code.
Performance. JIT causes a slight to noticeable delay in the initial execution of an application, due to the time taken to load and compile the bytecode. Sometimes this delay is called "startup time delay" or "warm-up time".
Advantages of just-in-time compilationJIT compilers need less memory usage. JIT compilers run after a program starts. Code optimization can be done while the code is running. Any page faults can be reduced.
the output of a simple test with rpart could be an advice not to use enableJIT in ALL cases:
library(rpart) fo <- function() for(i in 1:500){rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)} system.time(fo()) #User System verstrichen #2.11 0.00 2.11 require(compiler) enableJIT(3) system.time(fo()) #User System verstrichen #35.46 0.00 35.60
Any explanantion?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With