Tomas Kalibera, the newest member of the R Core Team, has been working for the last several years with fellow Core Team member Luke Tierney implementing R's byte-code compiler and interpreter. Byte-compiling R code often improves its speed of execution, and usually happens without you having to take any explicit action. R's base and recommended packages are compiled when R is installed, and your scripts and functions are automatically compiled "just-in-time" as you execute them.
At the useR!2017 conference last month, Tomas Kalibera gave a very interesting talk: Taking Advantage of the Byte Compiler. In particular, he shows that not all R code is equivalent to the byte compiler. For example, the byte compiler has most impact on code that works with scalar arithmetic in tight loops. There's also some kinds of R code that takes a relatively long time to compile, which can swamp the performance benefits if the function is compiled at execution-time. (Package authors can avoid this for their users by declaring that their packages be compiled on install, by including Byte-Compile: yes
in the DESCRIPTION file.) For package authors and R users that care about performance, you can find lots of tips like this in the talk embedded below.
For even more details on the implementation of the byte-compiler, take a look at the document A Byte Compiler for R by Luke Tierney.
Comments
You can follow this conversation by subscribing to the comment feed for this post.