An Optimization Odyssey

Hey, I’m Saveliy Yusufov. I first started this blog shortly after I finished college to document the fascinating ideas I encountered as a new software engineer. Although I paused for a while, recent learning experiences have reignited my passion for sharing these insights. Sometimes I find neat ways to optimize code using a bunch of different resources to help me, and this blog now serves as a way to document the solutions and my experiences.

If you’re curious about me, I took a non-traditional path after high school. Shortly after finishing high school, I went into the army, where I served as an Army Ranger. I never desired to go to college, and I always thought I’d go into the medical field (at the behest of my family). In a twist of fate, I discovered programming. That motivated me to go to college to study computer science once I transitioned out of the service. I pursued a CS & Math combined major to prove to myself that I’m not just bad at math (yes, I loathed math in high school and even failed multiple math classes).

Shortly after I started programming, I became consumed by the idea of making my code as performant as possible. Initially, this obsession took the form of fixing low-hanging fruit in code (e.g., replacing sequential lookups in a large array with a hashmap). Once I discovered the joys of concurrency and parallelism, I became obsessed with leveraging them to improve performance as well. My latest obsession has been SIMD. Namely, utilizing SIMD to achieve significant performance improvements.

Note: All opinions presented in this blog are my own and not my employer’s.

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?...

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

From FFTs to Quantum Simulations: The Butterfly Connection

Introduction Today, I want to bring your attention to the butterfly diagram. By the end of this post, I hope to show you that this stunning visualization also gives you almost everything you need to know in order to implement a quantum state simulator and the Fast Fourier Transform (FFT). For a while I have been working on a quantum state simulator, Spinoza. During the implementation and performance tuning of the simulator, I encountered a memory access pattern that comes up often in the context of Digital Signals Processing (DSP)....

24 July 2024 · 11 min · 2212 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....

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 · 314 words · Saveliy Yusufov

Homomorphism Inverse to Inverse

A beautiful proof and elegant proof covered in Abstract Algebra.

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