fastr
fastr copied to clipboard
Java interop - Multi-threaded access not allowed for R
While testing the Java Parallel Optimization Package, which can evaluate a function, its gradient and its Hessian in parallel, the following exception occurred:
java.lang.IllegalStateException: Multi threaded access requested by thread Thread[pool-2-thread-1,5,main] but is not allowed for language(s) R.
If enabling multi-threading for R is not doable in a short time, I think that another option is to execute this Java package on a different JVM than the one on which FastR is running. How can I exchange data between the two? How can I serialize an R function to read it in a Java program?
Hello Marduk,
we'll need to investigate our options here a bit more but a simple approach that can work for you now is to synchronize access to FastR: it is now allowed to execute from multiple threads at the same time but as long as you execute from at most one thread at a time it should be fine. So putting something like synchronize(myLockObject) { .... } around all places that call back to FastR should work for now.
For further investigation: can you share some example or point us to concrete API from the Java Parallel Optimization Package that you would like to use like this?
Hi Stepan,
Will this work also if calling fastR from Ruby? Can we polyglot with fastR without having to add the single thread flag?
Thanks!
Em ter, 17 de set de 2019 às 11:38, Stepan Sindelar < [email protected]> escreveu:
Hello Marduk,
we'll need to investigate our options here a bit more but a simple approach that can work for you now is to synchronize access to FastR: it is now allowed to execute from multiple threads at the same time but as long as you execute from at most one thread at a time it should be fine. So putting something like synchronize(myLockObject) { .... } around all places that call back to FastR should work for now.
For further investigation: can you share some example or point us to concrete API from the Java Parallel Optimization Package that you would like to use like this?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/oracle/fastr/issues/106?email_source=notifications&email_token=AA6QP4KF5JMJ5AWBY36U5ZTQKDTXPA5CNFSM4IXQQK62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD64YCSI#issuecomment-532250953, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6QP4MCIGXB5SHBIOJU7FTQKDTXPANCNFSM4IXQQK6Q .
-- Rodrigo Botafogo
Hi Rodrigo,
in theory yet but you would have to make sure that every piece of code that is going to invoke FastR (like accessing R vector from Ruby) is synchronized with some lock. I am not sure if that is doable with reasonable effort. We should eventually add support for this into the interoperability infrastructure.