RServe File Sharing Library Code

Is it possible that processes spawned by RServe share some common libraries loaded once into memory? Imagine that I need to execute the following code on 100 different RConnections at a time.

library(libraryOfSize40MB)
fun()

This means that I need about 3.9 GB of memory to load the library. I would prefer to load the library once and then execute a fun()hundred times so that I can run this on a cheap host.

Maybe this is useful? https://github.com/su/Rserve/blob/master/NEWS#L40-L48

+4
source share
1 answer

It is possible. You must start RServe from the R shell using run.servewhich is preceded by loaded libraries:

library(Rserve)

#load libraries so all connections will share them
library("yaml")
library("reshape")
library("rjson")
library("zoo")
(...)
library("stringr")

run.Rserve(debug = TRUE, port = 6311, remote=TRUE, auth=FALSE, args="--no-save", config.file = "/etc/Rserve.conf")

Each new connection will be able to see these libraries

library(RSclient)
con = RS.connect(host='10.1.2.3')
RS.eval(con, quote(search()))
> #lots of libraries available
+3
source

Source: https://habr.com/ru/post/1598053/


All Articles