Advancing Async Computing in R
The R ecosystem continues to evolve with powerful tools for modern computing challenges, and mirai stands at the forefront of asynchronous evaluation frameworks. This latest release brings significant enhancements that solidify mirai’s position as the most sophisticated approach to async computing in R.
mirai (ミライ, Japanese for “future”) represents a paradigm shift in how R handles asynchronous operations. Built on the robust foundation of nanonext and NNG (Nanomsg Next Gen), mirai offers:
Unlike traditional parallel computing approaches in R, mirai handles many more tasks than available processes (and requires no file system storage) through its inherently queued architecture.
The most notable behavioural change is the upgrade to mirai()
’s .timeout
argument. mirai now automatically cancels ongoing operations upon timeout. This feature provides better control over long-running tasks and prevents resource wastage from abandoned computations.
# Timeout now actively cancels the operation
<- mirai({
m long_compute_intensive_task()
.timeout = 5000) # Cancels after 5 seconds },
serial_config()
now accepts vector arguments to register multiple custom serialization configurations simultaneously.
This enhancement simplifies working with diverse data types across distributed systems, for example both Arrow Tables and Polars DataFrames.
host_url()
has been upgraded to return all local IP addresses, named by network interface. This provides a more robust solution for distributed computing setups, especially in complex network environments:
# Returns all available interfaces
host_url()
# Example output:
# eth0: "tcp://192.168.1.100:5555"
# wlan0: "tcp://192.168.1.101:5555"
Three new functions enhance the developer experience:
register_serial()
: allows package authors to register serialization configurations for all daemons()
callson_daemon()
: indicates whether evaluation is occurring within a mirai call on a daemondaemons_set()
: checks if daemons are set for a given compute profileFor HPC environments, daemons()
now supports initial synchronization exceeding 10 seconds.
This enhancement is particularly valuable for large-scale distributed computing setups where network latency or resource provisioning may require longer connection times.
As of R 4.5, mirai is now one of the official base R parallel cluster types.
# Create a miraiCluster directly
<- parallel::makeCluster(6, type = "MIRAI") cl
mirai’s promises integrate seamlessly with Shiny applications, enabling truly responsive user interfaces. Developed in collaboration with Joe Cheng (creator of Shiny), it’s the only event-driven solution that fully integrates with Shiny’s capabilities, and also scales to complex apps with many users Link to vignette examples.
mirai’s mirai_map()
provides the underlying implementation for purrr’s new purrr::map(.parallel = TRUE)
and friends (currently in the development version). Purrr is one of the core tidyverse packages, and a respected functional programming tookit that is depended upon by data scientists and developers alike.
mirai users benefit from a longstanding collaboration with Will Landau at Eli Lily, where his targets package adopted crew (built on mirai) as its default HPC backend. The life sciences industry runs heavy-duty pipelines across HPC and cloud environments on a constant basis, providing real life assurance of mirai’s reliability.
Installation is straightforward:
install.packages("mirai")
Basic usage remains elegantly simple:
library(mirai)
# Launch background daemons
daemons(6)
# Evaluate asynchronously
<- mirai({
m expensive_computation()
})
# Continue other work...
# Retrieve result when needed
<- m$data result
mirai represents more than an incremental improvement — it’s a testament to R’s evolution as a modern computing platform. With its sophisticated architecture, robust error handling, and seamless integration with contemporary R workflows, mirai enables developers to build scalable, responsive applications that leverage distributed computing resources effectively.
The combination of simplicity in design and power in execution makes mirai the go-to solution for:
As the R ecosystem continues to modernize, mirai stands as a cornerstone technology, bridging the gap between R’s statistical heritage and the demands of contemporary distributed computing.
For more information, visit the mirai website or explore the package on CRAN or GitHub. Join the community in shaping the future of async computing in R.
For attribution, please cite this work as
shikokuchuo (2025, May 23). shikokuchuo{net}: mirai 2.3.0. Retrieved from https://shikokuchuo.net/posts/26-mirai-230/
BibTeX citation
@misc{shikokuchuo2025mirai, author = {shikokuchuo, }, title = {shikokuchuo{net}: mirai 2.3.0}, url = {https://shikokuchuo.net/posts/26-mirai-230/}, year = {2025} }