Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible shortcomings for using JIT with R?

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?

like image 364
Tal Galili Avatar asked Apr 11 '12 13:04

Tal Galili


People also ask

Does R use JIT?

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.

Is JIT faster than compiled?

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.

Is JIT compilation slower?

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".

What are the advantages of a JIT compiler?

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.


1 Answers

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?

like image 186
Robert Avatar answered Sep 24 '22 21:09

Robert