RServe share library code

大城市里の小女人 提交于 2019-12-19 03:35:59

问题


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

library(libraryOfSize40MB)
fun()

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

Maybe this is helpful? https://github.com/s-u/Rserve/blob/master/NEWS#L40-L48


回答1:


It is possible. You have to run RServe from R shell using run.serve 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")

Every new connection will be able to see this libraries

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


来源:https://stackoverflow.com/questions/31433840/rserve-share-library-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!