I have a lengthy function which takes about 1s to run in Rust, but 6s when I call that function from R. The function takes some vectors of data, such as means and standard deviations, does some sampling, and then does some dataframe stuff in Polars. It returns a 2D ndarray. The only thing different between the two is changing the return value from df.to_ndarray::<Float64Type>().unwrap() to df.to_ndarray::<Float64Type>().unwrap().try_into().unwrap().
I time the body of the Rust code and print it, which is nearly equal to the total time the function runs, so I know converting the arguments/return value between Rust and R objects is not causing this.
They have all the same dependency versions and are both running on nightly Rust. What might be causing such a slowdown? I ported this code to Rust to make it a lost faster and this has unfortunately caused a major performance regression.
I can provide the function if needed, it is just large and requires a lot of data to run.
I have a lengthy function which takes about 1s to run in Rust, but 6s when I call that function from R. The function takes some vectors of data, such as means and standard deviations, does some sampling, and then does some dataframe stuff in Polars. It returns a 2D ndarray. The only thing different between the two is changing the return value from
df.to_ndarray::<Float64Type>().unwrap()
todf.to_ndarray::<Float64Type>().unwrap().try_into().unwrap()
.I time the body of the Rust code and print it, which is nearly equal to the total time the function runs, so I know converting the arguments/return value between Rust and R objects is not causing this.
They have all the same dependency versions and are both running on nightly Rust. What might be causing such a slowdown? I ported this code to Rust to make it a lost faster and this has unfortunately caused a major performance regression.
I can provide the function if needed, it is just large and requires a lot of data to run.