logoalt Hacker News

Dissecting the CPU-memory relationship in garbage collection (OpenJDK 26)

49 pointsby jonasnlast Tuesday at 1:49 PM16 commentsview on HN

Comments

jonasnlast Tuesday at 2:23 PM

Hi HN, I'm the author of this post and a JVM engineer working on OpenJDK.

I've spent the last few years researching GC for my PhD and realized that the ecosystem lacked standard tools to quantify GC CPU overhead—especially with modern concurrent collectors where pause times don't tell the whole story.

To fix this blind spot, I built a new telemetry framework into OpenJDK 26. This post walks through the CPU-memory trade-off and shows how to use the new API to measure exactly what your GC is costing you.

I'll be around and am happy to answer any questions about the post or the implementation!

show 4 replies
cogman10yesterday at 10:45 PM

At my work, one thing that I've often had to explain to devs is that the Parallel collector (and even the serial collector) are not bad just because they are old or simple. They aren't always the right tool, but for us who do a lot of batch data processing, it's the best collector around for that data pipeline.

Devs keep on trying to sneak in G1GC or ZGC because they hyper focus on pause time as being the only metric of value. Hopefully this new log:cpu will give us a better tool for doing GC time and computational costs. And for me, will make for a better way to argue that "it's ok that the parallel collector had a 10s pause in a 2 hour run".

show 1 reply
mattclarkdotnettoday at 1:10 AM

Sorry if this is obvious to Java experts, but much as parallel GC is fine for batch workloads, is there a case for explicit GC control for web workloads? For example a single request to a web server will create a bunch of objects, but then when it completes 200ms later they can all be destroyed, so why even run GC during the request thread execution?

show 1 reply
cvossyesterday at 10:13 PM

> This freed programmers from managing complex lifecycle management.

It also deceived programmers into failing to manage complex lifecycles. Debugging wasted memory consumption is a huge pain.

firefly2000yesterday at 10:12 PM

Are there plans to elucidate implicit GC costs as well?

show 1 reply