Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    P

    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.

    Visit blogHN submissions
    Systems & PerformanceLanguages & Compilers
    What HN says

    HN commenters cite it as evidence that ZGC gives sub-millisecond pauses, around 50 microseconds on average, in discussions of Java garbage collection.

    Stats for nerds
    21HN people shared it
    9linked in comments
    219story points
    Mar 2023last shared
    2020people per year2023

    Top posts on HN

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

    What HN people wrote when they linked it

    • xxsOct 2021

      >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

    • doikorMar 2021

      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)

    • throwaway189262Sep 2020

      > 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

    • pronMar 2021

      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.

    • vips7LJun 2021

      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/csharp-all-about-span-exploring-a-new-net-mainstay

      [1] https://malloc.se/blog/zgc-jdk16

    • ZababaJul 2021

      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.

    Related

    Stefan Krausestefankrause.net43 people

    A first look at WebAssembly performance

    Stefan Krause
    Personal · last shared 2023
    ZeroTurnaround Blogzeroturnaround.com86 people

    Java 10 and beyond – a look at the potential language change

    ZeroTurnaround Blog
    Company · last shared 2018
    Aleksey Shipilëvshipilev.net112 people

    JVM Anatomy Quarks

    Aleksey Shipilëv
    Personal · last shared 2026
    Microsoft Java Blogdevblogs.microsoft.com/java15 people

    Preview of Microsoft Build of OpenJDK

    Microsoft Java Blog
    Company · last shared 2026
    KC Sivaramakrishnankcsrk.info44 people

    OCaml on Baremetal Shakti RISC-V Processor

    KC Sivaramakrishnan
    Personal · last shared 2026
    Mechanical Sympathymechanical-sympathy.blogspot.com79 people

    Memory Access Patterns Are Important (2012)

    Mechanical Sympathy
    Personal · last shared 2026
    Brian Goetzcr.openjdk.java.net/~briangoetz53 people

    Pattern Matching for Java

    Brian Goetz
    Personal · last shared 2022
    Wingologwingolog.org237 people

    FFS SSL

    Wingolog
    Personal · last shared 2026