What are the benefits in the integration of rust language into the kernel?
Announcement
Collapse
No announcement yet.
The Latest Progress On Rust For The Linux Kernel
Collapse
X
-
Originally posted by Azrael5 View PostWhich are the benefits in the integration of rust language into the kernel?
But for the kernel itself - drivers are the obvious benefit. Both from a bug-standpoint, but also from a code-review/quality standpoint where _some_ issues with badly written C code won't be possible in Rust and this might (speculation) result in easier upstreaming of external driver written in Rust.
- Likes 4
Comment
-
Originally posted by cl333r View PostNot to me...
​​Was it the author himself perhaps? It's completely nonsense. That is not how the Rust borrow checker works. A 5 minute tutorial in Rust would have shown that. Hint: the Rust borrow checker is run at *compile time* not *run time*.
- Likes 8
Comment
-
Originally posted by tomas View PostWhy did this comment even get 1 "like"?
​​Was it the author himself perhaps? It's completely nonsense. That is not how the Rust borrow checker works. A 5 minute tutorial in Rust would have shown that. Hint: the Rust borrow checker is run at *compile time* not *run time*.
This is not 100 percent true that borrow checker in rust is 100% compile time only there are particular things with rust that are borrow checked at runtime. This does explain some of rust overhead with rust programs designed particular ways as they are triggering the runtime borrow checking. Most cases the program can be designed other ways in rust to avoid this.
- Likes 2
Comment
-
Originally posted by tomas View Post
Why did this comment even get 1 "like"?
​​Was it the author himself perhaps? It's completely nonsense. That is not how the Rust borrow checker works. A 5 minute tutorial in Rust would have shown that. Hint: the Rust borrow checker is run at *compile time* not *run time*.
Comment
-
Originally posted by oiaohm View Post
https://users.rust-lang.org/t/refcel...-runtime/52721
This is not 100 percent true that borrow checker in rust is 100% compile time only there are particular things with rust that are borrow checked at runtime. This does explain some of rust overhead with rust programs designed particular ways as they are triggering the runtime borrow checking. Most cases the program can be designed other ways in rust to avoid this.
If you don't use RefCell then you won't incur this runtime cost when Rust is doing its borrow checking. Its usually possible to refactor code that uses RefCel to not use RefCel by refactoring it into functions, since Rust's does compile time borrow checking analysis on the function level.Last edited by mdedetrich; 12 September 2021, 09:38 AM.
- Likes 7
Comment
-
Originally posted by mdedetrich View PostSure but this is also somewhat misleading because you are using a RefCell, in other words you know that you are going to pay a runtime cost by using this abstraction. In C++ there are also abstractions which add runtime overhead but you know that only in this case you will get this overhead because you used this abstraction. This is what the whole "you only pay for what you use" mantra. Its not like the Rust compiler will silently insert runtime checks to satisfy the borrow checker, you are basically opt'ing into it.
If you don't use RefCell then you won't incur this runtime cost when Rust is doing its borrow checking. Its usually possible to refactor code that uses RefCel to not use RefCel by refactoring it into functions, since Rust's does compile time borrow checking analysis on the function level.
The reality is that Rust borrow checker was not design as compile time only. The rust borrow checker design to be a min runtime borrow checker were everything that it believes can be solved at compile time is not runtime checked. But there are cases around particular data structures where borrow checker has to work a runtime and that is part of rust design.
Yes you have a lot of people say that rust borrow checker does not have runtime parts this is false. Rust program will have runtime borrow checking if you use particular features that is the hard fact of the matter. Rust compiler at this stage does not have any warning flag options to show when you have used any of the options with runtime borrow checking this is kind of a weakness.
Please note one of the reasons why the Linux kernel stuck with C over C++ was to avoid the abstractions problem of adding extra runtime code. This is why it would be good for rust to have some extra compiler flags for inserted code issues.
Yes some of the examples people put up of rust code losing to C or C++ are in fact code that could be recoded to avoid using runtime borrow checker code so close the performance gap. Yes this would be good to be able to say put a build flag on have compiler say this is using runtime borrow checker in the following areas. Of course it might not be safe to remove the runtime borrow checking without doing even worse code on performance. Yes the reason why C/C++ might be winning in some of these cases is being thread unsafe and may other issues.
- Likes 2
Comment
-
Originally posted by oiaohm View Post
https://users.rust-lang.org/t/refcel...-runtime/52721
This is not 100 percent true that borrow checker in rust is 100% compile time only there are particular things with rust that are borrow checked at runtime. This does explain some of rust overhead with rust programs designed particular ways as they are triggering the runtime borrow checking. Most cases the program can be designed other ways in rust to avoid this.
In terms of speed, RefCell does add one or two dozen instructions around resource acquisition and release points. And, for most applications, those acquisition and release points will be so sparse it will never be a real problem. However, in those applications they somehow turn out to be frequent, either by the nature of the procedure being implemented or, most likely, by the developer's unfamiliarity with the language and environment, they could always be replaced or rewritten at wish.
Asserting that "the borrow checker has a runtime component", then, is just plain wrong. The borrow checker runs entirely inside the compiler and that's it. Whatever access control mechanisms a developer decides to use after the fact are entirely their own choice, and those can, of course, range from no overhead at all, in the case they just decide for bypassing the compiler time checker with unsafe code, to very mildly expensive, in the case of wrapping a global structure around an RwLock or something, or hell, they could even write their own mechanism, if that's what they want.
- Likes 4
Comment
-
Originally posted by oiaohm
The reality is that Rust borrow checker was not design as compile time only. The rust borrow checker design to be a min runtime borrow checker were everything that it believes can be solved at compile time is not runtime checked. But there are cases around particular data structures where borrow checker has to work a runtime and that is part of rust design.
Yes you have a lot of people say that rust borrow checker does not have runtime parts this is false. Rust program will have runtime borrow checking if you use particular features that is the hard fact of the matter.
Also, wasn't oxide designed after-the-fact and is not used within the compiler?
- Likes 6
Comment
Comment