Making R 300x times faster!
Vložit
- čas přidán 20. 06. 2024
- Someone came to me with some slow R code and asked if Rust could make it faster. Here is how I made their R code 300 times faster using Rust. After, someone schools me and makes the code 2000 times faster using base R and data.table. Sometimes an over emphasis on the tidyverse and data frames can make folks write slower code!
0:00 - Intro
1:00 - The problem
1:35 - Reviewing the code
2:50 - Function break down
3:50 - Lookup vectors
4:35 - function rewrite
5:05 - benchmark lookup vector
5:20 - function rewrite
7:50 - Rust R function
17:15 - Benchmark
17:25 - a better approach
18:00 - 3rd circle of hell
20:45 - R is fast - Věda a technologie
My girlfriend says you are a good presenter even though she does not care for programming. Great video ! :)
Great video, Josiah!
For benchmarking, just a fun FYI in case you didn't know, you can do `summary(benchmark_obj, relative = TRUE)` and it will compare the two in relative terms, which is neat!
First time of hearing about lookup vectors using the names feature... super smart. Good video!
Amazing video!
I’ve been using R for about 2 years now and I had no idea how fast R could be. Didn’t know how powerfull Vectorization could be.
Have you ever tought about making a series of videos about Vectorization? Like starting from the more obvious ways one should implement Vectorization in “every-day code”, and go on to more advanced and nuanced examples.
I’d love to watch that. But thats just an idea.
Anyway, congratz for the awsome video. I’ve just found your channel, but already subscribed!
Thank you so much for these well-made, interesting and inspiring videos of yours!! :)
Love this video and ur content! ❤
this video is awesome! thank you!!!!
R is fast; good use of data.table is super fast
So my takeaway is if “Rust go Brrrr”, the “R (can) go!Hmmmm”
Definitely! And also, if you know how to use R is goes VROOOOOOMMMMM. It's ungodly fast if you know how to use it right :)
@@josiahparry I suggested Hmmm as y’a know speed of light :)
Please share with me your handsome Rstudio theme! Many thanks in advance!
You can get my theme on Github gist.github.com/JosiahParry/082f417c01a87c3a35674bc6fb830f2d
For summing an entire iterator, you may use .sum(). I don't know if it will work with the extender crate, but worth trying out ;)
Nice! Thats good to know. I don't think it will work with extendr because you need to handle NAs that could come form the R side. I'll ask the discord :)
Primitive types like Rint and Rfloat can be sum()-med
@@ilia__k if an NA is present it will result in NA, no?