NVMe driver in rust with similar perf to C impl (Linux Plumbers 2022)
twitter.com
twitter.com
Just watched and enjoyed it. The Q&A section had a lot of positive and encouraging feedback. This made me optimistic about Rust kernel support being merged soon, and seeing more of this in the near future.
I don't know the exact goal/purpose of this new driver (does it aim to be used in production eventually?) But I suspect that a review on this driver code will help in validating or refuting or improving the work being done by the Rust for Linux crew
In my opinion, in the discussion after this talk folks did mention some pointers of why this was achieved. Although, for the same driver, there is a 2.6% drop in perf when used with 3 disks.
In practice it depends on LLVM
Thanks for the pointer :)
Rust's &mut borrow is like a pointer guaranteed to be non-null but also guaranteed to never point to memory that can be accessed by another borrow. Or in other words, &mut can't be aliased by other borrows. If you ever try to alias a &mut borrow, the program won't compile.
C's restrict is kind of similar, but it's far less used than &mut. That's because if you violate aliasing restrictions of restrict, it won't generate a compiler error, but will cause UB!
Anyway in Rust, a &mut has exclusive access to a piece of memory, and the compiler may theoretically make use of this fact in optimizations. However, LLVM isn't yet as good as it could be :( first, I think it doesn't implement yet the real good stuff that GCC has (I found this https://internals.rust-lang.org/t/fyi-ibm-is-working-on-llvm... from 2020 but I don't know the state of it), and worse, what it currently has is very buggy, so sometimes the Rust compiler is forced to disable it :(
So, you have this: https://stackoverflow.com/questions/57259126/why-does-the-ru...
And, is this code compiling with the rust compiler written in rust? (namely not pulling in the SDK this horrible c++ diareha which is gcc).
I have not checked rust syntax lately, but hopefully, it did not become insane like the c++ one (and what they are trying hard to do with C). Even at the start, I really did not like the hardcoding of strings directly into the syntax, but at least it had the decency to not require a garbage collector.