Tune Code Before Your Garbage Collector

One tiny log line wrecked speed tests, and the comments instantly turned into a roast

TLDR: The benchmark’s bombshell was that removing one unnecessary log line improved worst-case slowdowns far more than swapping Java’s memory cleanup system. In the comments, developers spiraled from “uh-oh, we log everything” to a full-on fight about bad habits, overengineering, and whether C++ was waiting in the parking lot all along.

A spicy little benchmark post about Java memory cleanup somehow turned into a full-blown comment-section identity crisis. The big reveal? The author says choosing a fancy garbage collector—the part of Java that cleans up unused memory—mattered way less than simply stopping one redundant log line from being written over and over. In plain English: the app was slowing itself down by constantly jotting notes to itself, and once that was removed, the “best” cleanup system changed completely. That alone had readers doing double takes.

The loudest reaction was basically: wait, are our logs the real villain? One commenter admitted this gave them “considerable pause” because nearly every class in their codebase starts with logging turned on. Another immediately went into interrogation mode, asking whether the logs were going to the console, a file, or a network collector—because if one tiny logging choice can cause chaos, people want receipts. Meanwhile, others used the moment to launch broader philosophy wars. One compared this kind of performance shortcut to caching, warning that once teams lean on it, they "lose their brains" and the whole app starts depending on the wrong thing.

And yes, the old language war showed up right on cue. A commenter dropped a Bjarne Stroustrup quote about not producing garbage in the first place, basically summoning the C++ crowd. That inspired an instant clapback calling C++ a “failed experiment that just keeps going.” So the benchmark may have been about latency, but the real entertainment was watching developers argue over whether the problem is logging, garbage collection, or civilization itself.

Key Points

  • The article benchmarks Java event-to-response latency at 50,000 messages per second for 30 minutes using JLBH on Chronicle-FIX.
  • Adding one SLF4J log line per message significantly worsened tail latency, especially at p99.99.
  • Moving log output to tmpfs reduced latency substantially, showing that log I/O location materially affected results.
  • Removing redundant SLF4J logging lowered p99.99 latency by roughly three orders of magnitude compared with the logged case.
  • After workload optimization, the relative ranking of garbage collectors changed, with Parallel GC producing the best p99.99 result and Shenandoah generational the worst in that final test.

Hottest takes

"people have lost their brains" — hinkley
"I don't like garbage" — einpoklum
"a failed experiment that just keeps going and going" — drob518
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.