Per Liden

malloc.se · Personal blog · on HN since 2020

Per Liden, a developer of the JVM's ZGC garbage collector, posts release-by-release updates on ZGC features and performance.

What HN saysHN commenters cite it as evidence that ZGC gives sub-millisecond pauses, around 50 microseconds on average, in discussions of Java garbage collection.
21HN people shared it
16linked it in comments
9stories submitted
219story points
4 years agolast shared
2020people per year2026

Most-shared posts

  1. 1
    ZGC – What's new in JDK 16
    14 people · 209 points · first shared 2021 · 101 comments on HN
  2. 2
    ZGC Using -XX:SoftMaxHeapSize
    5 people · 2 points · first shared 2020 · discussion on HN
  3. 3
    ZGC – What's new in JDK 18
    2 people · 3 points · first shared 2022 · discussion on HN
  4. 4
    ZGC – What's new in JDK 15
    2 people · 3 points · first shared 2020 · 1 comments on HN
  5. 5
    ZGC – What's new in JDK 14
    1 people · 2 points · first shared 2020 · discussion on HN
  6. 6
    Zgc oracle developer live 2020
    1 people · first shared 2021

What HN people wrote when they linked it

mohaneds · 2022-06-02
You're right; Java has ZGC, a best-in-class garbage collector with average pause times of 50 microseconds while still having great throughput. https://malloc.se/blog/zgc-jdk16#:~:text=With%20concurrent%20thread%2D…
xxs · 2021-10-15
>I didn't find any other measurements on the internet, please point me to them if you find them. It has been years since I have written thousands sockets servers (used in forex), yet even a couple milliseconds per write would have made the entire operation useless. >another explanation could be false sharing effects that I didn't know well at the time. False sharing sucks, of course, but milliseconds seems way way too much again penalty. You'd need all cores updating the same cache line, even then I doubt it'd be that bad. Could it be the virtualization layer? (again I have run 'that' on bare metal only) >I think it should be possible to do some similar stuff with multiple readers and/or writers Multiple writes should be avoided entirely, contention on writing is what prevents scaling - false sharing is pretty much that. A writer honoring the readers is pretty simple - each reader has its own pointer and the write should fail (or spin) when the buffer is full. I think that's quite a classic structure and indeed - it requires no extra memory to communicate/hand-off. About latency - this is java's current GC that does still has a compaction phase. https://malloc.se/blog/zgc-jdk16
throwaway189262 · 2020-09-20
> How do you find a reasonably small Xmx that doesn't lead to OutOfMemoryError exceptions? That's tough to figure out. In new versions of Java, I think 14+, if you use ZGC collector it will return unused memory to the OS. Memory options vary depending on collector, but new versions of ZGC support "soft max" heap size and uncommit. Together it might be close to what you're looking for https://malloc.se/blog/zgc-softmaxheapsize I should mention the GC situation was worse until the last few years. Until ZGC and Shenandoah came around, Java still didn't collect frequently but when it did there were long pauses. This is what V8 and Go's collectors were designed to avoid. They have more overhead from collecting frequently, but low pauses. With the new Java collectors you get the best of both worlds. You can set heap ratios and such for older collectors to decrease Java memory use with those, but IMO you're better off using ZGC and uncommit these days
layer8 · 2022-12-02
ZGC (JVM) now has guaranteed maximum pause times of 500 microseconds, with average pause times of just 50 microseconds: https://malloc.se/blog/zgc-jdk16 Pause time is not the same as cycle time, but it’s what’s important for reactivity.
plandis · 2022-08-09
Low pause collectors exist explicitly for this purpose. ZGC and Shenandoah both trade throughput (more concurrent collections) for extremely low pause times: https://malloc.se/blog/zgc-jdk16
the8472 · 2022-08-09
> - no global gc pauses, low-latency ZGC has sub-millisecond pauses https://malloc.se/blog/zgc-jdk16 And afaik azul's C4 collector has no global pauses, only per-thread pauses (which are also short)
majou · 2021-11-23
Max pause times of 0.5ms is what got me really interested. It feels like a huge trade-off of GCs is almost completely gone. https://malloc.se/blog/zgc-jdk16
pjmlp · 2021-08-02
Enjoy, https://malloc.se/blog/zgc-jdk16 I guess Oracle, IBM, Azul, PTC, Microsoft can provide the necessary data about their pauseless GC implementantions to any relevant customer.
Zababa · 2021-07-18
From what I understand Python uses reference counting, which is a type of garbage collection that allows you to have deterministic performance, almost no "pauses" but at the cost of performance. About the consistency, I think that's not a GC problem in general. For example, Java's ZGC has constant pause times: https://malloc.se/blog/zgc-jdk16.
vips7L · 2021-06-01
C# has added a lot of control over memory layout. Span [0], structs etc. I am hoping they add more D like features (@nogc) to the language. Java itself has just made strides on reducing GC pause times [1]. Granted, this isn't optional GC, but does D really give you that? Don't you lose the entire ecosystem and stdlib with -asBetterC? Why would I choose that over rust/zig/c++? FWIW, I am a big fan of D. [0] https://docs.microsoft.com/en-us/archive/msdn-magazine/2018/january/cs… [1] https://malloc.se/blog/zgc-jdk16
haglin · 2021-04-05
Hotspot has sub-millisecond GC pause times. "But as long as your system isn’t heavily over-provisioned, you can expect to see average GC pause times of around 0.05ms (50µs) and max pause times of around 0.5ms (500µs)." https://malloc.se/blog/zgc-jdk16
pron · 2021-03-25
You're mixing two things here: memory management and memory layout. This "pointer-heavy programming" is, indeed, a bad fit for modern hardware in terms of processing speed due to cache misses, which is why even Java is now getting user-defined primitive types (aka inline types, aka value types), but in terms of memory management, in recent versions OpenJDK is pretty spectacular, not only in throughput but also latency (ZGC in JDK 16 has sub millisecond maximum pause time for any size of heap and up to a very respectable allocation rate: https://malloc.se/blog/zgc-jdk16 and both throughput and max allocation rate are expected to grow drastically in the coming year with ZGC becoming generational). As far as performance is concerned, GC can now be considered a solved problem (albeit one that requires a complex implementation); the only real price you pay is in footprint overhead.
perliden · 2021-03-23
ZGC in its current form trades a bit of throughput performance for better latency. This presentation provides some more details and some performance numbers (a link to the slides is also available there). https://malloc.se/blog/zgc-oracle-developer-live-2020
Shadonototro · 2021-06-18
Try ZGC, sub 1ms pauses https://malloc.se/blog/zgc-jdk16
doikor · 2021-03-23
There is a worst case that is much worse then the now mentioned 1ms. Namely really big change in allocation rate in which case the gc cycle does not finish before running out of memory (ZGC uses allocation rate to determine when to start next gc cycle). In that case ZGC stops allocations ("Allocation Stall" in gc logs). But this is basically a failure mode and should not happen during normal operations at all. Though you can configure for this in a couple ways if you run into this issue 1. By telling it to treat some amount of heap as the max that is not actual max when it comes to it calculating when it should start next gc cycle. (-XX:SoftMaxHeapSize) https://malloc.se/blog/zgc-softmaxheapsize 2. Increasing the amount of concurrent gc threads so they will finish their work faster (-XX:ConcGCThreads) 3. Just run really large heap so the "run a gc cycle even if we don't need to based on allocation rate" gc cycle keeps the heap in check. Though after JDK 15 we have not had to mess with any of these. Prior to that we had to adjust soft max heap size a bit. With JDK 16 it should be even better I guess (should be upgrading sometime next week)

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close