Rust Performance Resources

A curated list of resources for optimizing code, with a focus on Rust. General Rust Specific The Rust Performance Book (great starting point for beginners and those new to Rust) How to avoid bounds checks in Rust (without unsafe!) Performance Cheat Sheets Latency Numbers Every Programmer Should Know Bit Twiddling Hacks Open Source Books Algorithms for Modern Hardware Performance Analysis and Tuning on Modern CPUs Memory Array of Structs vs. Struct of Arrays Data alignment for speed: myth or reality? Floats Taming Float Sums Tools and Libraries Profiling Samply Benchmarking Criterion.rs Divan Multithreading Rayon crossbeam SIMD Crates Portable SIMD API soa-rs SIMD-itertools Vectorized Solutions Parallel Prefix Sum with Simd Domain Specific Resources HFT When a Microsecond Is an Eternity: High Performance Trading Systems in C++ FFT Construction of a High-Performance FFT Mixed Data Layout Kernels for Vectorized Complex Arithmetic Notes on FFTs: for implementers Found this helpful? Have suggestions? Feel free to reach out on GitHub.

14 September 2024 · 1 min · 156 words · Saveliy Yusufov

From FFTs to Quantum Simulations: The Butterfly Connection

Exploring the connection between the FFT butterfly diagram and quantum state simulation, with Rust implementations for both.

24 July 2024 · 10 min · 2114 words · Saveliy Yusufov

Python Truthiness and Equivalence Classes: A Mathematical Perspective

Introduction Recently, I ran into a bug in Rust while I was checking if bits were set in a u64. fn is_bit_set(n: u64, k: usize) -> bool { n & (1 << k) == 1 } Let’s run it on some input and see what happens. fn is_bit_set(n: u64, k: usize) -> bool { (n & (1 << k)) == 1 } fn main() { let n = 51; for k in 0..6 { println!("{}", is_bit_set(n, k)); } } true false false false false false This makes no sense. We know the binary representation of 51 is 110011, so we expect to see: ...

30 November 2023 · 5 min · 1013 words · Saveliy Yusufov

Recv

Intro to the recv system call, and a common mistake beginners make when employing recv.

10 February 2021 · 2 min · 312 words · Saveliy Yusufov

Homomorphism Inverse to Inverse

An elegant proof from Abstract Algebra showing that group homomorphisms preserve inverses.

13 January 2021 · 1 min · 132 words · Saveliy Yusufov