Pass array into Rust thread without cloning #5009
Replies: 3 comments 2 replies
-
Have you considered using Arc::clone()? It is supposed to be faster than cloning a vector since it does not clone all the data, just a reference instead. Additionally, when using Arc::clone() one can share a value between multiple threads. I am not quite sure whether it can be done without cloning. However, if you will use just a one thread you can pass the ownership. |
Beta Was this translation helpful? Give feedback.
-
Anyways, my solution to overcome the slow data marshaling is by passing the file descriptor from Python and mmaping it in Rust. I might also experiment and profile passing a Rust memoryview into Python and letting Python populate the view. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, I am wondering if there's a way to pass
&[u8]
into a Rust thread without having to clone it.input_bytes
can be very very large, perhaps larger than 100 GB. Cloning wouldn't be feasible here for performance and memory reasons. Doingto_vec()
made this binding 6x slower than its non-cloned counterpart.My guess is that there is no way as this is also the reason why Polars is so slow when creating a
DataFrame
.Beta Was this translation helpful? Give feedback.
All reactions