14 Approaches and Design Alternatives
A parallel R runtime has to choose between known alternatives at every layer: processes or threads, message passing or shared memory, tracing garbage collection or reference counting, AST walking or bytecode, copying or zero-copy transfer. The pages here put each pair side by side. Each records benefits, drawbacks, what existing runtimes chose, and the current hypothesis for R.
Processes vs Threads and Shared Memory, in the concurrency section, use the same comparative method.
Purpose of the comparisons
A runtime design is a sequence of interrelated choices: how to isolate work, how to share data, how to manage memory, how to execute code. Each choice has costs and benefits, and the costs show what the design is optimized for.
A design document that announces apartments tells you little until you know what they were chosen over: free threading, separate processes, or actors.
Each page compares two or three approaches on the same nine dimensions. Seeing what existing runtimes chose, and why, lets you judge whether that choice fits your own constraints.
Scoring
Every comparison page in this section evaluates options using these nine dimensions:
- Isolation. How well does the design separate state? Can failure in one component leave others unaffected?
- Data movement. How much data must be copied or transferred between components?
- Startup cost. How long until the first result? Does initialization happen once or per-task?
- Steady-state overhead. What is the per-operation cost once initialized?
- Memory behavior. How does memory usage scale with the number of components or data size?
- Portability. Does the design work across Unix, macOS, and Windows? Does it require specific CPU features?
- Package compatibility. Can existing native R packages run unchanged?
- Failure containment. If one component crashes, does it kill others?
- Determinism. Is execution order predictable? Can results be reproduced exactly?
Each page scores its options on all nine, in this order, in one table.
After this section
You will understand the major design tradeoffs in parallel R. You will recognize why certain architectures were chosen (apartment model, per-interpreter garbage collection, message passing) and what costs they incur.
You will be able to read a proposal for a new R runtime and ask the right questions: Does it handle native packages? What is the startup cost? How does it handle large shared data?
The pages
Processes vs Threads vs Interpreters. How to parallelize: separate OS processes, threads sharing one interpreter, or multiple isolated interpreters in one process.
Shared Memory vs Message Passing. How threads exchange data: direct pointer sharing or serialization through a queue.
Reference Counting vs Tracing Collection. How to reclaim memory: update counters on every reference or scan the object graph periodically.
AST Walking vs Bytecode. How to execute code: interpret the source tree directly or compile to an intermediate bytecode first.
Copying vs Zero-Copy Transfer. How to send data between interpreters: full duplication or mapping into shared memory.
Before this section
Read Multi-Interpreter Architecture to understand why R needs multiple execution contexts and what isolation means in practice.
Read Why the Apartment Model First? to see how these tradeoffs led to the apartment model decision.
Where this leads
Once you have seen the design space, Design Questions explores unresolved tradeoffs specific to this project: shared immutable vectors, per-interpreter garbage collection, isolated environments.
Per-Interpreter Garbage Collection covers the question of whether to run one collector for all interpreters or one per interpreter.
Decisions documents the choices that have been made and the constraints that forced them.
Comparisons of locks and actors, stack and register VMs, and OS threads and green threads are planned for when measurement shows which of those tradeoffs change real R workloads.