JDK 27 G1/Parallel/Serial GC Changes

(tschatzl.github.io)

41 points | by 0x54MUR41 6 hours ago ago

14 comments

  • smallnix 5 hours ago ago

    > selecting something else depending on arcane environmental conditions was more of a burden than an advantage

    What is being referred to here? Does "else" refer to ZGC, Shenandoah?

    What does arcane env conditions mean?

    • aatos 4 hours ago ago

      It's in the JEP (https://openjdk.org/jeps/523):

      > We made G1 the default collector for server environments in JDK 9 (JEP 248). At that time, testing showed that Serial had significant advantages in throughput and footprint in constrained environments with a single CPU or less than 1792 MB of physical memory. We therefore adjusted the JVM's GC selection algorithm to choose Serial in such environments.

  • kasperni 5 hours ago ago

    Are people still dealing with GC issues?

    I find that it basically just more or less works out of the box on modern JVMs.

    • thangalin 2 hours ago ago

      > Are people still dealing with GC issues?

      Have you tried real-time audio processing for digital radio communications on a JVM that requires sub-millisecond latency on older, temperature-hardened CPUs?

      • pron an hour ago ago

        Use ZGC.

    • hylaride 4 hours ago ago

      There are edge cases where GC issues can crop up, in particular specific "serverless" models (eg AWS lambdas) where the JVM can get "paused" between executions and GC doesn't cleanly run, causing memory to trend upwards until the next cold-start happens (especially if you're running it within a docker container yourself). Limited CPU situations that can exist in these kinds of runtime environments also limit GC in several ways, too.

      • skullone 4 hours ago ago

        What's it like running JVM inside serverless? Python gets interesting enough when it pauses waiting for another call sometimes, the JVM seems like it'd introduce its own interesting things :o

        • hylaride 3 hours ago ago

          Other than some GC issues, meaning we had to give it more memory than we'd otherwise like thereby making them a bit more expensive, it's mostly been fine. The key to ephemeral java is keeping scope limited and not using it when cold starts matter (which can cause a bit of jitter in execution lag). Our use case was asynchronous, so it worked.

          We wanted to investigate using the native AWS java lambdas with snapstart and/or using parallel GC, but the place I used them at a year ago was under the tyranny of product having complete control of our backlog, so we didn't get to go that far with it or even more serious tech debt for that matter.

          More memory may or may not even be much of an issue depending on your workload. If you can handle the odd OOM error it would have been fine, but for our use case lambdas were so cheap that it didn't really matter, outside of us techies preferring to do it "right". Having the max execution time be less than 15m could also minimize the heap bloat at the cost of more cold starts.

    • geodel 2 hours ago ago

      Perhaps. That's why actual JVM GC developers are talking about it.

    • kelseyfrog 4 hours ago ago

      It's selection bias. There's a huge number of GC language users, but those who experience problems tend to be the ones who comment.

      You're right; the vast majority of people use GC just fine and go about their day. We should update little to none when we see evidence of GC hardship.

      • 2001zhaozhao 23 minutes ago ago

        I sometimes run into browser JavaScript GC issues for browser games specifically but on the JVM side i have not run into any pain points for a long time.

        (I run a first-person shooter Minecraft server, and for this and other fast-paced gaming in general pause times under a millisecond or so is generally good.)

      • stmw 3 hours ago ago

        It depends a lot on the scale of the system, which often means that those fewer users are actually doing things that are more complex and more valuable - either at the lower end or at the high end.

  • stmw 4 hours ago ago

    GC's haven't freed us from manual memory management, you just do all that manual work with environment variables, or making sure to "pick the right collector for the job", or debugging performance or heap size issues, or chasing down weak references or confused finalizers.

    • pron an hour ago ago

      > you just do all that manual work with environment variables

      You really don't anymore. For the past several years, Java's GCs mostly pick the right settings automatically, except for heap size, which will be taken care of soon (https://openjdk.org/jeps/8377305). The reason heap size isn't automatic is that with moving collectors it determines the CPU/RAM tradeoff, and doing that in a more natural way isn't trivial, but we have the algorithm now and will merge it soon.

      > or making sure to "pick the right collector for the job"

      There are really only four options, most of which are easy to choose among: Parallel for batch jobs where only throughput matters, ZGC for interactive applications where latency matters a lot, and then consider either G1 or Serial if there's a problem with those choices.

      As someone who's worked for a long, long time solving manual memory management issues, the amount of effort required isn't just in a different ballpark, but in a different city. Sure, spending a few hours a year to reconsider your settings isn't nothing, but it isn't even remotely in the same category of pain with manual memory management (or even automatic memory management, but with malloc/free underneath).