# Tips for speeding up R with byte compilation

July 29, 2013
By

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

A byte-compiler for R code — which can improve the execution performance of R functions — was introduced in R 2.13.0, and was automatically applied to the bundled packages in R 2.14.0. Drew Dimmery provides some good advice for identifying targets amongst your own R functions for compilation:

I have some function that will be repeatedly executed n times. You’ll want to make n large enough that it takes some fairly significant chunk of time — like maybe 20 seconds or so. You will very likely see an improvement through compilation. The first replicate will be faster when uncompiled, but every subsequent iteration will tend to be faster through compilation. If you’re using a lot of external functions in this test function, don’t expect miraculous speed increases.

Drew also provides instructions to set environment variables for R to automatically compile packages at the highest level of optimization, which you can find at the link below.

Drew Dimmery: JIT compilation in R (via Pablo Barberá)