Articles on Optimization

Last updated: 2023/01/18

Top deep-dives on Optimization

Refactoring a checksum until it runs 100 times faster

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.
Some highlights:

  • Pro unrolled loops
  • Senior used unsafe
  • Hacker converted a long to a short vector
  • Expert reverses the Endianess

Low Hanging Fruits in Frontend Performance Optimization

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.

Making Reasonable Use of Computer Resources: Part 2

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.

The Speed of Time

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.

Visualizing Performance-Critical Dependency Chains.

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.

The Surprising Impact of Medium-Size Texts on PostgreSQL Performance

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.

Scaling Causal's Spreadsheet Engine from Thousands to Billions of Cells: From Maps to Arrays

Simon Hørup Eskildsen explains the optimization process for a Go program when you've exhausted easy problems found with profiling.

Postgres Query Optimization: LEFT JOIN vs UNION ALL

David Christensen demonstrates neat optimization of a postgres query by replacing LEFT JOIN with UNION ALL.

Why Train When You Can Optimize?

Justin Meiners illuminates the wonderful world of optimization by implementing a drawing assistant in JavaScript that'll help you draw straight lines, circles, and squares on a canvas.

How we diagnosed and resolved Redis latency spikes with BPF and other tools

Matt Smiley tells a tale concerning "a Redis instance acting exclusively as a least recently used (LRU) cache".
Some highlights:

  • 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

How to avoid bounds checks in Rust (without unsafe!)

Sergey "Shnatsel" Davidoff discusses the runtime cost of bounds checks on indexing and how to avoid them without resorting to unsafe code.
Some highlights:

  • 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

Technology Deep Dive: Building a Faster ORAM Layer for Enclaves

Graeme Connell discusses how Signal updated its enclaves to use ORAM for better performance and obscurity.

Want to see more in-depth content?

subscribe to my newsletter!

Other Articles