[Rcpp-devel] RInside and multi-threading
edd at debian.org
Sun Feb 12 16:00:10 CET 2012
On 12 February 2012 at 18:13, Darren Cook wrote:
| > | I found , suggesting that this is okay for RServe. Implying it would
| > | be okay for RInside too?
| > At present, Rserve is set up to fork (on OS X and Linux)...
| I took it to mean it forks per connection. The quote below is talking
| about threads in a client application sharing a connection to an Rserve
| server. Assuming I didn't misunderstood that much, it implies R can
| handle non-eval commands in parallel, (which in turn would imply that
Yes, but only via fork() which creates separate R instances. R itself is
single-threaded (and will mopst likely remain that way). So in multi-
threaded apps using RInside you have to be careful---with a mutex lock before
and after a single-threaded R segment, things can work fine.
| RInside would also be okay).
As I was trying to say: RInside does not do any forking (yet).
It could conceivably fork each time an app instantiates an RInside object,
but then at the end that does not buy you much as you still need to
coordinate the results from the main program. Rserve, running similar to a
webserver, has many distinct and unrelated clients---whereas RInside would
presumably be called from one larger program. It's just different.
| (That may not be the case if Rserve is serializing the incoming requests
| on each connection... but in that case there would be no need for them
| to have written the "don't eval in parallel" warning.)
| A chain of assumptions... it be nice if someone had actually tried it.
| (If no one else has, then I will get to it; eventually.)
Rserve has been out for many years and has been well documented. You can read
up on it over at the rosuda.org site.
Hope this helps. We're getting a little off-topic here.
| > | : http://www.rosuda.org/Rserve/
| > | "Rserve is thread safe across connections, but eval methods are not
| > | thread safe within one connection. This means that multiple threads
| > | should not use the same connection unless they guarantee that no eval
| > | calls are run in parallel."
| Darren Cook, Software Researcher/Developer
| http://dcook.org/work/ (About me and my work)
| http://dcook.org/blogs.html (My blogs and articles)
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx
More information about the Rcpp-devel