What is the most expensive arithmetic operation for a CPU?
A division.
It takes ~10-30 cycles when a subtraction only takes 1.
Modified a running sum to replace a division on every tick with a simple subtraction.
Benchmarked on an isolated core.
Gain: ~36%
#lowlatency
p99.99 went down in all tests.
max latency was slashed.
#lowlatency
“Flash was born because the tablet failed and it died because the tablet returned”
Remember when you couldn’t play video in a browser without it? Amazing story.
youtu.be/UWuB74Gz510
New low-latency C++ home lab:
- a mobile dev box: Ubuntu VM running on a MacBook
- a fixed “production” box: bare metal Linux on a refurbished 2013 MacBook with Intel chip for deep access to perf stat measurements and hardware tweaks.
primal.net/e/nevent1qqsrzfma…
Recycling ♻️: installed Ubuntu on my MacBook pro 2013.
Removed the swollen battery before it explodes and burns my apartment.
The objective? Have an Intel-based bare metal environment rather than a VM, so that I can practice perf stat, hardware counters, TMA and flame graphs.
We don't need to use virtual functions when the complete set of possible classes is known at compile time.
So those clever interface-based calls that used to give us a boner in regular C++ or C# are not for a low latency hot path context.
youtu.be/NH1Tta7purM
Very good material packed with nuanced technical approaches to make C++ systems a little bit faster (and how to measure it)
youtu.be/sX2nF1fW7kI
Laurie Kirk invents a word to describe the situations where the programmer knows something the operating system doesn’t.
It’s really what low-latency coding is all about: have the OS stop guessing and trying to help.
youtu.be/ScwvInRZdKE











