Comments (1)
Here's my user take on parallelism:
One of hte main reasons to use Rust is because of its "fearless concurrency." As a novice user of Rust, I find this to be one of the major reasons to use it! Rayon and tokio are game changing. I personally use both rayon and tokio in tandem with extendr but it requires a lot of hoop jumping.
There are three ways that I would use parallelism with extendr.
- Using rust native types as a parallel iterator, collecting into a native Rust type, and converting into an R type
- This is supported today
- Using a rust native type as a parallel iterator, collecting into an Robj / R type
- this is not supported today.
- Using R native types as a parallel iterator and collecting into an Robj / Robj
- this is not supported today.
- Example use case: I have a
List
of structs (Geom
s in{rsgeo}
) which I iterate over in parallel and call a method on it, for examplex.unsigned_area()
and collect it intoDoubles
Today I introduce parallelism by taking a List
of structs, cloning them into a Rust owned vector, using Rayon, then collecting into a Vector of non-extendr types. Then in another iteration convert them into an extendr type. There becomes 2 extra iterations over my vector in that case to use parallelism. In some cases that has caused parallel iteration to be slower and less efficient than single threaded nature. Example here.
I would like to be able to do at least 2. I envision this as having some rust type that I can introduce as a parallel iterator. A real example is here. Ideally I could take a Vec<Vec<u8>>
and process this in parallel using rayon. In each iteration I create an Robj
that I would like to collect::<Vec<Robj>>()
. After processing, I would turn this into a List::from_values(res_vec)
. However, this is not possible because even if the Robj
has not seen R yet, it cannot be sent between threads. I'd like something like SendRobj
or UnsafeRobj
or something that I can create in parallel and collect on a main thread so I can at least create Robj
s in parallel.
I understand the difficulty of #3 and don't foresee that being feasible right away. Nor would I need to do that. But I find 2 to be frustrating becasue the data (at least from my perspective) as not even seen R yet it just has an Robj type.
from extendr.
Related Issues (20)
- doctests fails on windows with "LINK : fatal error LNK1181: cannot open input file 'R.lib'" HOT 2
- extendr-impl: returning &Self from impl always returns the calling item
- `IntoDataFrameRow` not implemented for `Robj` HOT 1
- `test-macro-snapshot.R` does not test R & Rust integration HOT 1
- Type check `Dataframe<T>` when used as a function argument.
- Using `Vec<bool>` as a function argument is not possible
- Replace manual conversions to TryFrom/Try traits HOT 5
- How to generate wrapper function only (we should call it via `Call`), but don't generate function in `extendr-wrappers.R` file. HOT 5
- Wrapper structs do not have `inherits()` method
- Create `row_iter()` and `col_iter()` methods for `RMatrix`
- Generalize the possibility of putting `struct` or `enum` in the input or output argument HOT 5
- Cannot extract factor column as Integers HOT 2
- Extendr doesn't create the ALTREP class in the supposed way? HOT 2
- `ToVectorValue` implemented for `&str` and `String` but not `Rstr` HOT 4
- [brainstorm] Roadmap for 2024
- `extendr-macros` may not use `libR-sys`
- Currently `#[extendr(use_rng = true)]` makes use of libR-sys, and this needs to be dealt with.
- Remove `libR-sys` from `tests/extendrtests`, as it is our r integration test, and we should mimic actual users, which may not include `libR-sys`.
- Support for u32 slice removed - workaround HOT 3
- how to use `&[T]` and is `&mut [T]` possible HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extendr.