Stop the world
10 years ago, when I started a new job, one of my first tasks was to evaluate various garbage collectors.
Many traditional Java collectors periodically stop the application to clean up memory. In the JVM world, this is called a Stop the World event. You run your service, memory fills up, and then everything halts while the garbage collector sweeps through the heap.
One of the collectors I looked at was from Azul. They claimed that GC pause time stayed remarkably flat even as the heap grew.
When I looked into how it worked, it initially felt like cheating.
They hadn't magically made the cleanup work disappear. Instead, they made the collector work concurrently with the application. By using read barriers, memory could be compacted while application threads kept running. There was still a cost: the application paid a small overhead on reading object references, while background threads did the work concurrently.
I remember thinking: that's a trick. You didn't eliminate the work, you just spread the cost out instead of making the entire application stop and pay for it all at once.
I thought about this from time to time, especially when dealing with chores I didn't really want to do. It motivated me to do them on the spot instead of deferring them.
Today, waiting at a traffic light, I realized I was tense. My first thought was that I should find time to start meditating, but then I remembered the GC example. It's better to take a couple of deep breaths on the spot instead of waiting for a Stop the World event.
Inhale, exhale. Right on the main thread.