-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Considerations when using extendr concurrently #298
Comments
We do have some limited thread safety, but short of putting everything through a mutex, it will never be recommended to call R functions concurrently. The one place we do want to use concurrency is when doing vector operations. We can do this now using rayon Altrep-aware parallel iterators would be good, for example, as well as parallel csv/tsv file iterators. Rayon gives us:
|
Agreed.
Is this possible in general? I'm wondering if it's guaranteed to be safe to access to an ALTREP vector concurrently. If it's CSV/TSV file, it sounds fine, but I guess it's not always the case. |
I am honestly scared of concurrent R (that is, in-process concurrency). I have used MRAN R (R by Microsoft) that featured Intel MKL libraries that support multi-threading, but it was confined to complex matrix operations in large data sets. Do you know if there are any good articles on R GC and its internals? I was trying to learn if it is compacting and how it deals with fragmentation, but found no good resources. |
Sorry for filing a vague issue. I guess one of the main reasons to use Rust is concurrency. On the other hand, R is not designed for concurrent programming.
For example,
Device
, which is notSend
, in async functions (For this particular issue, I'd appreciate if you give me some advice on Discord!).Integers
andDoubles
concurrently, but they are notSend
and notSync
. I guess we cannot mark them asSend
or evenSync
because ALTREP is not safe to use concurrently. So, in this case, they need to convert it to a slice before passing the data to some concurrent processing.Of course much part of above is due to my lack of experience on concurrent programming, but I think it's great if extendr provides some guidance for the concurrent usages.
The text was updated successfully, but these errors were encountered: