I'm trying to call a function from the flexsurv package using opencpu. I am running on OSX Sierra.
I have modified my opencpu .conf file to include flexsurv in the list of preloaded packages:
{
"enable.api.library": true,
"enable.api.apps": true,
"enable.api.bioc": true,
"enable.api.cran": true,
"enable.api.gist": true,
"enable.api.github": true,
"enable.api.user": true,
"enable.api.tmp": true,
"enable.cors" : true,
"enable.post.code": true,
"error.showcall": true,
"gist.cache": 300,
"github.cache": 86400,
"cran.cache": 86400,
"public.url" : "https://public.opencpu.org/ocpu",
"smtp.server" : "localhost",
"httpcache.post": 300,
"httpcache.lib": 86400,
"httpcache.git": 900,
"httpcache.gitapi": 120,
"httpcache.tmp": 86400,
"httpcache.cran": 86400,
"httpcache.static": 31536000,
"httpcache.bioc": 31536000,
"key.length" : 9,
"appspaths": "/usr/local/lib/opencpu/apps-library",
"repos": "http://cran.rstudio.com",
"rlimit.as": 2e9,
"rlimit.fsize": 1e8,
"rlimit.nproc": 50,
"timelimit.get": 600,
"timelimit.post": 90,
"timelimit.webhook": 900,
"preload": ["ggplot2", "lattice","survival","flexsurv"]
}
I then start open cpu and make the following call in curl:
curl localhost:7210/ocpu/library/flexsurv/R/pgompertz/json -d "q=[0,1,2,3]&shape=0.001&rate=0.001" -w "%{time_total}\n" -o /dev/null
This call takes about 1.4 seconds, despite being an extremely simple and fast function call that should take no time at all.
By comparison, calling rnorm to draw 10,000 random normal samples returns in less than half a second:
curl localhost:7210/ocpu/library/stats/R/rnorm/json -d "n=100000" -w "%{time_total}\n" -o /dev/null
Why does the comparatively simple flexsurv call take so much more time? Is preload not working? If so, how can I fix this? If not, what is the causing the additional latency?
Any help is much appreciated...