Abstract
R is a numerical computing environment that is widely popular for statistical data analysis. Like many such environments, R performs poorly for large datasets whose sizes exceed that of physical memory. We present our vision of RIOT (R with I/O Transparency), a system that makes R programs I/O-efficient in a way transparent to the users. We describe our experience with RIOT-DB, an initial prototype that uses a relational database system as a backend. Despite the overhead and inadequacy of generic database systems in handling array data and numerical computation, RIOT-DB significantly outperforms R in many large-data scenarios, thanks to a suite of high-level, inter-operation optimizations that integrate seamlessly into R. While many techniques in RIOT are inspired by databases (and, for RIOT-DB, realized by a database system), RIOT users are insulated from anything database related. Compared with previous approaches that require users to learn new languages and rewrite their programs to interface with a database, RIOT will, we believe, be easier to adopt by the majority of the R users.
Introduction
Data scientists frequently rely on R for its high-level abstractions and powerful statistical tools. However, R is fundamentally memory-bound, assuming that all data can fit within the system's RAM. When datasets exceed this limit, the operating system triggers "swapping," leading to severe performance degradation known as thrashing. Traditional solutions require users to rewrite code in low-level languages or manually manage SQL databases, both of which impose a steep learning curve. RIOT (R with I/O Transparency) addresses this by providing the performance benefits of a database backend while maintaining the familiar R syntax.
System Architecture and Methods
The RIOT-DB prototype leverages a relational database (MySQL) to handle storage and computation. It achieves transparency through several key mechanisms:
- Generics-based Interception: RIOT-DB introduces
dbvectoranddbmatrixtypes. By utilizing R's generics mechanism, it intercepts standard mathematical operators and translates them into database-compatible actions. - Deferred Evaluation: Instead of immediate computation, RIOT-DB builds expression trees that represent sequences of operations. These are eventually converted into SQL views.
- Inter-operation Optimization: By delaying execution, the system can optimize across multiple lines of code, such as pipelining results to avoid temporary files or performing selective evaluation.
As shown in the figure above, RIOT-DB maintains the state of variables within an expression tree, allowing it to track dependencies and optimize the final execution plan before any data is actually fetched or computed.
Experimental Results
The performance of RIOT-DB was evaluated against standard R using synthetic benchmarks, including large-scale vector processing and matrix multiplication chains.
The results demonstrate that as vector size increases beyond the physical memory limit, plain R's performance craters due to excessive Disk I/O. In contrast, RIOT-DB maintains linear scaling. Notably, a "strawman" approach—simply offloading individual queries to a database without inter-operation optimization—often performs worse than plain R due to database overhead. RIOT-DB's success stems from its ability to optimize the entire computation pipeline, significantly reducing both I/O and total execution time.
Conclusion and Future Work
RIOT-DB demonstrates that I/O transparency can bring database-level performance to R users without requiring them to learn SQL. While the current prototype uses a relational backend, future iterations will explore specialized storage managers like ChunkyStore to further reduce overhead. Additionally, the team aims to develop cost-based models for materialization logic to decide when it is more efficient to save intermediate results to disk versus recomputing them.
Summary updated