The Ra Extension to R

Note: This project has been deprecated. It is not supported with the latest versions of R.

Ra is functionally identical to R but provides just-in-time compilation of R loops and arithmetic expressions in loops. This makes such code run much faster.

An example

    jit(1)                     # turn on just-in-time compilation
    for(i in 1:na)             # example convolution code
      for(j in 1:nb)
        ab[i+j-1] <- ab[i+j-1] + a[i] * b[j]
With na and nb bigger than about 100, the loop runs about 25 times faster. With na and nb equal to 10, the loop runs about 10 times faster. See here for timing tests.

The idea is that all you have to do is add a jit(1) statement before loops. The R code is compiled on the fly to bytecode which is executed internally by an interpreter in C.

It's not a panacea

The JIT compiler makes arithmetic loops faster, but not other code. The jit statement must be inserted by the programmer before loops. You will not see speed increases in most existing packages.

Note also that code in functions called from jitted code is not jitted.


A case study (an overview document using the distribution-of-determinant example).

The help page describes the jit() function. It is part of the jit package on CRAN. The jit package works in conjunction with the Ra executables. Under R, the jit() function has no effect.

Timing tests
Implementation notes (describe the design approach)
Reading List
Some email with replies
Internal data structures (JPEG file)
Internal state machine (PDF file)

Download for Windows-7 64-bit

On Windows-7 64-bit systems, the simplest way to install Ra is to run the Windows Ra 1.3.1 Win installer (26 Aug 2011, based on R 2.13.1, about 3 MBytes). It's easy and you get the benefit of a faster version of R. You need to first have R 2.13.1 installed (64-bit build). You should uninstall your old version of Ra, if any, before installing a new version.

Note: this installer has currently been tested only on 64-bit Windows-7 systems. It has not been tested on other versions of Windows.

This README file tells you what the installer does.
The case study will give you an idea of what Ra can and can't do.

Source code

Current release 26 Aug 2011 ra_1.3.1.tar.gz based on the R-2.13.1 sources.
NEWS summarizes changes in each release.
Build instructions (also included in the tar file).
Remember to also install the jit package from CRAN.

Debian release prepared by Dirk Eddelbuettel
Simon Urbanek reports that Ra builds cleanly on Linux and Mac OS X.

Previous releases

Request for feedback

Your comments are always appreciated. Please use milbo AT sonic PERIOD net.


It is a pleasure to thank the following people for their contribution to Ra:
To Stephen Milborrow Homepage