R Developer to Sunlight
Read this if you write R daily but have not worked with parallel execution and want to use sunlight. By the end, you will understand fork, copy-on-write, serialization, worker pools and load balancing, and how they fit together in sunlight.
Processes versus Threads. sunlight uses processes because GNU R cannot run R code on more than one thread of a process, and the reasons for that run through most of this corpus.
Fork, Copy-on-Write, and the First GC. Forked workers share the parent’s memory pages for free until something writes to them, and a full garbage collection in the child writes the mark bit of every reachable object.
Serialization. Separate processes share no addresses, so everything that crosses becomes bytes and then becomes objects again.
Thread Pools. Why a pool of warm workers beats starting one per task, and what the pool costs you in exchange.
Work Stealing. Uneven tasks leave some workers idle while others still have work. Work stealing is one answer. sunlight uses a simpler one: it splits the input into chunks and hands the next chunk from one queue in the parent to whichever worker is free.
sunlight. The pieces assembled: a prewarmed template, forked workers, demand-driven dispatch of chunks, and per-task random streams that do not depend on worker count.
After this path you can judge when sunlight fits a workload: why its workers are forked from a template, why it checks a task’s free variables when the task is spawned, and why results come back in input order with random streams that do not depend on the worker count. For more depth, the sunlight page lists the CRAN Task View on high-performance and parallel computing, and R Internals <https://cran.r-project.org/doc/manuals/r-release/R-ints.html> covers the runtime underneath.