Articles on Optimization
Last updated: 2023/01/18
Top deep-dives on Optimization
Israel Lot tells the story of five different developers (looks like no genius entry yet, maybe it'll be one of you?), at different levels of expertise, attempting to optimize a checksum method, with varying levels of success. Optimizing stuff like this is usually overkill in 99% of cases, but it's a fun exercise nonetheless.
- Pro unrolled loops
- Senior used unsafe
- Hacker converted a long to a short vector
- Expert reverses the Endianess
There are few things more frustrating than navigating to a webpage and having to wait over three seconds to be able to do anything. "Alex, you're just a spoiled brat too used to fast internet" you say. No dear reader, I'm just a professional who understands that there are ways for solving this if you're not a lazy dev. Paweł Urbanek has written an in depth article on the topic, not only providing a variety of different methods for testing, but also offering a bunch of specific tips for cutting down load times.
As you sit at your desk, scratching your head thinking about how you could shave a few seconds off of the function you just wrote, you hear a faint whisper in the wind, "premature optimization is the root of all evil". Well if your function takes days to run, it's definitely not premature. In this short article, the author describes the steps taken to optimize a JSON parsing script that originally took "more than a day to run", down to about 15 minutes using some clever shortcuts.
People have been obsessed with measuring time since its beginning; probably because we have so little of it! Philosophy aside, Brendan Gregg's article describes how he managed to fix a 30% increase in write latency for a Cassandra database cluster when switching from CentOS to Ubuntu, just by changing how the time is measured.
Denis Bakhvalov "prove[s] that critical data dependency chains are increasingly becoming the only thing that matters for performance of a general-purpose application", and then goes on to demonstrate how to find and display them all pretty like.
When you're talking about Postgres databases, TOAST is an acronym for the system that handles when "large field values are compressed and/or broken up into multiple physical rows", so that they can be stored across Postgres' 8 kB pages. In this in depth article, Haki Benita first explains how TOAST works, then demonstrates it in action, and finally ties it back to the titular problem, with possible solutions thrown in at the end.
Simon Hørup Eskildsen explains the optimization process for a Go program when you've exhausted easy problems found with profiling.
David Christensen demonstrates neat optimization of a postgres query by replacing LEFT JOIN with UNION ALL.
Matt Smiley tells a tale concerning "a Redis instance acting exclusively as a least recently used (LRU) cache".
- Redis cache would suffer from bursts of very high latency and corresponding throughput drop
- Redis pretty much single threaded
- There's a "Key insights summary" section you should check out
Sergey "Shnatsel" Davidoff discusses the runtime cost of bounds checks on indexing and how to avoid them without resorting to unsafe code.
- Bounds checks are in place to prevent buffer overflow attacks
- The real-world performance impact of bounds checks is surprisingly low, with the greatest impact being in the 1-3% range (improvement in speed)
- Lots of info on profiling performance on different systems
Graeme Connell discusses how Signal updated its enclaves to use ORAM for better performance and obscurity.