Performance lints

If you are reading this book, these two lints will probably be the ones you will find more important than the ones Clippy does not warn by default. The first is pretty simple: if you want to share an integer between threads, using a Mutex is a really bad idea if you do not need to use it as a synchronization variable.

Usually, things such as counters will be much faster by using atomic types. Only pointer-sized atomics and booleans are stable at the time of writing, but the rest are also coming and can now be used in nightly Rust. You can spot this issue with the mutex_integer lint.

Also, you might be tempted to use std::mem::forget() to enable sending data to C APIs, or to be able to do some strange memory tricks. This ...

Get Rust High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.