crbcc

crbcc is an R package that compiles R code to bytecode using a C implementation. It is intended as a fast, drop-in alternative to the base compiler package, for cases in which a reduced compilation time could be beneficial, eg. in research. However using crbcc for minor performance improvements inside R’s JIT pipeline is also possible.

This project was developed as part of a bachelor’s thesis at FIT CTU.

Acknowledgement

When possible, crbcc mirrors the architecture and logic used in the original GNU-R compiler package by Luke Tierney. The original compiler Noweb document is available at https://homepage.cs.uiowa.edu/~luke/R/compiler/compiler.pdf, or distributed as an R base package, available under the GPL-2 license. Most documentation provided in the document is relevant to crbcc as well.

Features

Interface

Requirements

Install

From source (local checkout)

R CMD INSTALL .

or with the provided Make target:

make install

Quick Start

library(crbcc)

f <- function(x) {
  y <- x + 1
  y * 2
}

cf <- cmpfun(f, options = list(optimize = 2))
cf(10)

Compile an R file

library(crbcc)

cmpfile("script.R", "script.Rc")
loadcmp("script.Rc", envir = .GlobalEnv)

Compiler options

The compiler accepts options as a named list:

Example:

opts <- list(
  optimize = 2,
  suppressAll = FALSE,
  suppressUndefined = c("pi", "letters")
)

cf <- cmpfun(function(x) x + pi, options = opts)

Contributing

Contributions are welcome.

R CMD check .

Known limitations

mirror server hosted at Truenetwork, Russian Federation.