17 ms·
GC progress from JDK 8 to JDK 17
- vletal 5y agoI like how this reached the top page soon after "Go does not need a Java-style GC" (https://news.ycombinator.com/item?id=29319160 https://news.ycombinator.com/item?id=29319160). Moreover, are the significantly lower GC pause times help improve snappiness of GUI apps, such as IntelliJ IDEA?
- deleted 5y ago[deleted]
- fnord123 5y agoCurrent IntelliJ uses Java11 and has gotten slower over the past few years (anecdata from my own use) - so probably not.
- thies 5y agoSince 2020.x it's definitely slower. The addition of jetbrains space doesn't seem to help either and removing the plugin itself makes the whole ide unstable
- vips7L 5y agoI wish they would just release a light version, without all the database, spring integration, and other crap. I just want a light language server.
- absove 5y agowouldn't community edition fit the bill? Those things you mention are the main difference with ultimate.
- vips7L 5y agoNot sure. I moved to VS Code + Eclipse LS and it's such a more pleasurable experience. However, it doesn't support SBT which is the build tool my company uses.
- hocuspocus 5y agoThe community edition is definitely enough for sbt projects. Any reason you're using sbt for Java projects? That's an odd combination. Anyway, I believe Metals is getting close to supporting this particular use case if you want to keep using VS Code.
- vips7L 5y agoFor some odd reason my company chose the play framework + Java. It's one of the most baffling choices I've ever seen. I've actually managed to get the Java plugins to work with sbt, but it doesn't understand when a Scala object is imported.
- 5e92cb50239222b 5y agoTry power saving mode (look in ctrl+shift+a).
- matsemann 5y agoJust deactivate the plugins?
- hiram112 5y agoThis is what I've noticed too. Intellij has never exactly been speedy, but it had so many great features that it was worth it compared to other slow IDEs like Eclipse. And using a basic text editor like VIM or even VS Code with a big Java project isn't really feasible like it might be in other languages like Python or Node. However, now it is really bogging down. I'm sure it doesn't help that I've got several IDEs open along with some monstrosity of a "microservice" framework running half a dozen docker services and DBs on an older Macbook Pro, but it's true that app and OS devs tend to use all increases in CPU and ram, and so absolute performance and battery life never seems to get better over the years, regardless of how much the underlying hardware itself has improved.
- aenis 5y agoNot just slower, also energy hugry. My m1 max running pycharm loses about 10pct of charge an hour on their crappy bundled jvm, and around 4% on the latest java17-based ones, but does act weird at times when using them. Its probably down to metal vs opengl. Disappointing.
- pjmlp 5y agoThe GC might help, but it doesn't do magic when threads aren't used the correct way, too much stuff lands on the UI thread or synchronous IO is used all over the place.
- Erlangen 5y agoIntellij uses UseConcMarkSweepGC gc, which has been deprecated since Java 9. Jetbrains is still investigating the use of ZGC. https://youtrack.jetbrains.com/issue/IDEA-247824 https://youtrack.jetbrains.com/issue/IDEA-247824
- darksaints 5y agoHonestly this is the most frustrating thing about Jetbrains. Stop investigating shit and just use the new JVMs already. There is no excuse for using deprecated JVMs.
- melony 5y agoI don’t understand why they are not shipping their own bespoke GC to go with Intellij, Jetbrains is already building their own JVMs.
- astange 5y agoEdit the idea64.vmoptions config file and use the GC of your choice. I've been running with ShenandoahGC for quite some time now and it's been working great. Also, see https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr17_0_1b164.8 https://github.com/JetBrains/JetBrainsRuntime/releases/tag/j... for a JDK17 runtime for Intellij products. I've been running this too and it works great (but does require some tweaks to the vmoptions file).
- vips7L 5y agoI tried this last year but the version they shipped with IDEA didn't have ZGC and using an external JVM caused some weirdness in the GUI for me.
- 5e92cb50239222b 5y agoText can look pretty bad if you're using other JVMs without their patches.
- 5y ago
- Sankozi 5y agoSnappiness problems are often due to lazy loading Java classes. For example first time loading project settings takes 1+ seconds while next less than 0.5. This value might get lower later if JVM decides to optimize more some parts of UI application.
- fnord123 5y agoI don't think that's where the issues are. IntelliJ freezes when reindexing a project when you change branches from the command line.
- deleted 5y ago[deleted]
- edgyquant 5y agoThat’s the magic of HN (or maybe it’s a form of the Baader-Meinhof Phenomenon.) When one topic reaches the front page it seems like a couple more based around it hit the front page the same or next day, which allows us to expand on what we’ve learned.
- msie 5y agoI’ve given up on IntelliJ and java-based UI’s long ago. So disappointing.
- coliveira 5y agoThat's the right way to go. Like IntelliJ or not, Java is a legacy technology. I wouldn't want to depend on that.
- kaba0 5y agoLol, you are laughably bad to think that java is legacy. The JVM is improving with never before seen speed, has state of the art GCs, a very good JIT compiler, upcoming green threads that will make blocking code automagically unblocking and once Valhalla hits with value types, there really will be very few areas where java would not be applicable. And on top of that, there is also Graal, which is a novel way to run and optimize mixed-language code bases.
- justbaker 5y ago>Lol, you are laughably bad to think that java is legacy. Seriously. It might not be one of the hip new languages with unique features but it’s a very mature language that is well battle tested, has plenty of libraries available, and the talent pool is very deep for Java hires. It’s also something that stands the test of time —- write code in 1999 on an old Java version it will still likely run on that version today.
- gregaccount 5y agoLooking at that, why isn't ZGC the standard GC in Java 17?
- __s 5y agoOnly stabilized in Java 15
- kaba0 5y agoLatency and throughput are fundamentally opposite ends of the same axis. And perhaps the majority of Java applications prefer better throughput.
- twic 5y agoBut the graph in the article shows that ZGC now gets better throughput than G1! [EDIT no it doesn't] I suspect the answer is that ZGC is not considered mature enough, and has a higher memory overhead than G1.
- dralley 5y agoThere are also other GCs that are heavily competitive with ZGC, such as Shenandoah. It might make sense to see how they all pan out before choosing a new default.
- Sindisil 5y agoShenandoah isn't an Oracle maintained feature, so they'll never allow it to become the OpenJDK default (though another vendor make it so in their distribution).
- cpitman 5y agoNo, that graph may be hard to understand. It shows the relative improvement each GC has made since Java 8, not the absolute performance.
- 5y ago
- pjmlp 5y agoNote, only relevant for OpenJDK and the JVMs based on it, there are other GC available to other JVMs, including real time ones.
- pkoperek 5y agoGenuinely interested - could you share some good resources about it?
- Thaxll 5y agohttps://www.azul.com/ https://www.azul.com/
- pjmlp 5y agoFor example, in what concerns real time GCs, these are good books, "Hard Realtime Garbage Collection in Modern Object Oriented Programming Languages." https://www.amazon.com/Realtime-Collection-Oriented-Programming-Languages/dp/3831138931 https://www.amazon.com/Realtime-Collection-Oriented-Programm... The author is one of the founders of Aicas real time JVM, https://www.aicas.com/wp/products-services/jamaicavm/ https://www.aicas.com/wp/products-services/jamaicavm/ "Distributed, Embedded and Real-time Java Systems" https://link.springer.com/book/10.1007/978-1-4419-8158-5 https://link.springer.com/book/10.1007/978-1-4419-8158-5 PTC is the other company alongside Aicas, that still sells real time Java systems, https://www.ptc.com/en/products/developer-tools/perc https://www.ptc.com/en/products/developer-tools/perc IBM J9 has the evolution of the Metronome GC, https://www.researchgate.net/publication/220829995_The_Metronome_A_Simpler_Approach_to_Garbage_Collection_in_Real-Time_Systems https://www.researchgate.net/publication/220829995_The_Metro... And it has extensions for value types, via packed object data, https://www.ibm.com/docs/en/sdk-java-technology/7.1?topic=objects-advantages-using-packed-access-native-data https://www.ibm.com/docs/en/sdk-java-technology/7.1?topic=ob... Someone else already referred Azul, they also have extensions for value types, called object layouts, https://www.slideshare.net/AzulSystems/jvm-language-summit-object-layout-presentation https://www.slideshare.net/AzulSystems/jvm-language-summit-o... Then there are special flavours like microEJ or the Android Java snowflake.
- Thaxll 5y agoWhat is not shown is those benchmark is how much CPU is used for each GC. For example the latency for ZGC is much lower but does it means it uses more CPU than G1.
- deleted 5y ago[deleted]
- albertopv 5y agoCPU is almost never a real issue. When I worked with Sql Server we always had data compression enabled, a little more of CPU but much less IO to do.
- naruhodo 5y agoI came here to say something similar. ZGC and Shenandoah run the GC in extra threads. I don't see any mention of the number of cores in the article, or in the linked SPECjbb2015 benchmark [1]. It would be interesting to see how much of the improvement is just down to the use of extra "unused" cores, and how much CPU is actually used by the GC. Equivalently, run a CPU-bound task on one core and measure GC and application performance, with an eye on how much the fancy GC slows down the program. [1] https://www.spec.org/jbb2015/ https://www.spec.org/jbb2015/
- seanwilson 5y agoHow much do you need to worry about the GC causing frame stuttering when writing games now? Object pools are still important?
- zokier 5y agoWell, jdk17 was released just few months ago so I doubt anyone has real experience with it for gamedev. But considering that game heaps are relatively small (as in <100G) and modern Java GCs can manage consistent <1ms pause times, I'd imagine Java is more viable for gamedev from that point of view. I'd also emphasize that there is large spectrum of performance requirements for games and you can make quite a lot these days with relatively poor performance characteristics, and on the other hand in the top end Java probably is still not good enough.
- adgjlsfhk1 5y agoIMO java for gamedev is pretty much un-viable due to the lack of control over memory layout. You clearly can make it work (see Minecraft), but it just sounds painful, and there isn't a clear benefit.
- fulafel 5y agoThere is no control over it in pure standard APIs, but if you are shipping a game you could do it with JVM specific ways or even ship a custom / customized GC. But most games don't actually need this. I'd be more concerned about whether there's a JVM language you like over other non JVM options for a game.
- 5e92cb50239222b 5y agoMinecraft wouldn't be anywhere near where it is today if it was not written in Java (which made modding much easier compared to native code, and made heavy modding possible). So there is a strong benefit, it's just not very obvious.
- Thaxll 5y ago
- twic 5y agoShame this doesn't show the CMS collector, which was present in 8 and 11, but removed before 17. CMS was the go-to option for low-latency collection for a long time, so it would be good to see how it compares to the modern options. It would be particularly interesting from the perspective of someone working in a shop which still has lots of latency-sensitive-ish workloads running on JDK 8 with CMS!
- lmilcin 5y agoAlso, it would be interesting to see this progression from at least 1.4. By the time 1.8 was released I had the impression that GC is already pretty well optimized for throughput.
- twic 5y agoAlthough if your ulterior motive is to persuade people to upgrade beyond 8 and 11, you probably don't want to suggest that performance has basically plateaued.
- lmilcin 5y agoI don't see how this is bad. JVM is pretty well optimized and it is much closer to raw C performance than most other popular languages. You could also say that C is bad because its performance plateaued a long time ago.
- jonhohle 5y agoC maps more closely to assembly/hardware than most other languages. Saying C has plateaued gets pretty close to saying it’s hardware performance that’s plateaued.
- kaba0 5y agoC doesn’t map any more closely to assembly/hardware than most other low level languages. If anything, hardware tries to conform as much to C programmers as they can. Hell, now Java has much better SIMD support than C, even as a high level language.
- zokier 5y agoShenandoah GC is conspicuously missing despite having similar availability to ZGC and competitive performance characteristics.
- papercrane 5y agoIt would be good to see the numbers, but I suspect the reason is just that the author used the Oracle build of OpenJDK which doesn't include it.
- maxpert 5y agoI've used Shenandoah GC with great success and I recommend anyone considering ZGC (specially on Kube and container environments) to try Shenandoah first. You won't have to do additional work to enable large pages, yet your performance is pretty close.
- thomascgalvin 5y agoThose latency and pause-time numbers are pretty sexy. 200ms is still probably too high for some applications, but for everything I work on, this is incredible.
- hedora 5y agoThose are P99 latencies. Not sure how they measure, but my assumption is that, if you probe the JVM at a random point in time, ZGC (P99 = 0.1) will be unresponsive for 100us 1% of the time. That’s… not incompatible with being useable in a low latency service, but 100us is 2.5 x longer than a sync disk write these days, and they don’t report max latency. My take on the article is that GC has gotten quantifiably better since Java 8, but not qualitatively better: The types of projects that had to abandon Java due to GC (and JIT) latency 10 (or 20) years ago still shouldn’t consider using Java.
- kaba0 5y agoI’m by no means an expert but even the OS’s scheduler can cause pauses on the range of 1ms — so the applications that can’t use Java, cannot really use ordinary OSs to begin with, can they? Like, yeah, I would probably not write something like pipewire (linux’s new audio processing project) in Java, but other than that and like some really low latency trading niche (where FPGAs are dominant now as even general CPUs are slow), where would it preclude the usage of Java?
- adgjlsfhk1 5y agoThe Linux kernel has realtime and lowlatency versions that help a lot here.
- mcdonje 5y agoThe throughput & latency charts have JDK8 pegged at 100%. Since that's meaningless and the value is in the difference between the JDK versions, it should be represented as a delta.
- jimsimmons 5y agoThese GCs have a 1GB overhead when working with a 16GB heap. That’s 6% of your available memory. I was expecting modern GCs to be way more efficient so I’m kinda shocked this is what state of the art is. I also wonder how much of the progress to “Sub (200) millisecond” latency target is due us just having faster machines. I honestly have no model to tie this to actual performance of my code. I guess it translates but not really sure how. Not bagging on Java —— I am just surprised how inefficient an industrial strength GC can be. I understand why manual memory management still holds its own now.
- foldr 5y agoManual memory management can also have overhead due to e.g. fragmentation. I don't know if it approaches 6% in realistic scenarios.
- pkolaczk 5y agoWait, fragmentation is not included in that 6%. It is that a GC with no fragmentation will already suffer a 6% overhead. A region-based GC will suffer from additional temporary fragmentation on top of those 6% as well, because some segments can be filled only partially with live objects until they are compacted. That effect might be actually bigger because allocations are done only from contiguous space, and it can't just try to allocate from the "holes" until it compacts them. And you also need some additional room to do allocations from in order to avoid too frequent GCs. So I'm practice it is not 6% but sometimes 600%.
- foldr 5y agoYes, sure. But you do still need to compare the total overhead associated with manual memory management (which is not zero) to the total overhead associated with GC. It's an empirical question which is larger in any given case. And of course it depends on the implementation of malloc and the implementation of GC. I'm not expressing a view as to whether the overheads of manual memory management are typically comparable or not. I really don't know.
- ozim 5y agoWhich does not matter because most of stuff still rides Java 8.
- JanecekPetr 5y ago...and they're missing out, that's exactly the message. By the way, I'd be shocked if Java 8 was still more than half of the running server-side JVMs. There's a lot of them for sure, but I'd be willing to bet it's gonna be less than a half now, and declining.
- guenthert 5y agoThey continue to use Java 8 as they see to reason to change. Article like this are meant to motivate those laggards.
- tpxl 5y agoUsed to work on an application that mostly did string manipulation and we couldn't upgrade it from 8 to 9 (or 11). Java 9 got compact strings (8 bits instead of 16 per character) if you used only a subset of UTF-16 (the LATIN-1 charset apparently, which english is). We would have gotten a free speed and memory improvement but the ops refused to support it, even though we did everything ourselves ): So even if there's a reason to change, people wont do it.
- kaba0 5y agoJust sharing this really great benchmark series on JVM GCs, though it doesn’t include the latest versions of OpenJDK: https://jet-start.sh/blog/2020/06/23/jdk-gc-benchmarks-rematch https://jet-start.sh/blog/2020/06/23/jdk-gc-benchmarks-remat...
- dandotway 5y agoAs Java is generally the fastest GC'd language, what's the current state of Java gamedev? Once upon a time, this indie Java game called Minecraft became the most successful game of all time. But from the few minutes of research I just did, Java cannot be deployed to many commercially important systems - Nintendo Switch - PlayStation - iOS It appears Java is only still viable for Windows and Android, and the 1% Linux desktop market. There used to be the GCJ project which would in theory let you run Java anywhere you had a C/C++ compiler, but Oracle's litigiousness killed that because the Java[TM] "platform" must run the official Java[TM] bytecode. It appears C# via Monogame lets you deploy to all desktops (Win/Mac/Linux), mobiles (iOS/Android), and consoles (PS/Switch/Xbox). So ironically C# seems to now be the "write once, run anywhere" fulfillment of the original Java promise. [EDIT: grammar.]
- deleted 5y ago[deleted]
- JanecekPetr 5y agoFor native binaries, we now have https://www.graalvm.org/reference-manual/native-image/ https://www.graalvm.org/reference-manual/native-image/, but it probably doesn't yet work nicely with game frameworks? Not sure. There are some engines, frameworks: https://jmonkeyengine.org/ https://jmonkeyengine.org/, https://litiengine.com/ https://litiengine.com/, https://libgdx.com/ https://libgdx.com/, https://www.lwjgl.org/ https://www.lwjgl.org/. But I have no real experience with any of those.
- dandotway 5y agoSo I just spent some time looking at all of these you listed. With the exception of libGDX they are all essentially desktop-only (Win/Mac/Linux). LibGDX appears to support iOS/Android and HTML5 desktop browsers, but not consoles (Switch/PS/Xbox).
- armchairhacker 5y agoI’ve used libGDX. Porting to iOS/Android/HTML5 is honestly a pain. iOS is actually not that hard, I got it to work using RoboVM, but you have to do some research because the documentation is outdated. HTML doesn’t work with Kotlin because it compiles directly from Java, and because it compiles directly it probably has some extra quirks.
- bob1029 5y agoAs a .NET developer I am a little envious of all the GC knobs that Java developers get to play with. If I could have only 1 new GC thing from Microsoft, it would be the ability to totally disable GC during the lifetime of a process. I don't even want to be able to turn it back on. I have a lot of scenarios where I could get away with the cruise missile approach to garbage collection. No reason to keep things tidy if the whole world is gonna get vaporized after whatever activity completes. Why waste cycles cleaning things up when you could be providing less jitter to your users or otherwise processing more things per unit time?
- google234123 5y agoIs the .net gc still contained in one gigantic source file?
- ixmerof 5y agoyup, exactly
- akshat_h 5y agoI haven't personally used this, but does this work? GC.TryStartNoGCRegion Method Attempts to disallow garbage collection during the execution of a critical path. https://docs.microsoft.com/en-us/dotnet/api/system.gc.trystartnogcregion?redirectedfrom=MSDN&view=net-6.0#overloads https://docs.microsoft.com/en-us/dotnet/api/system.gc.trysta...
- bob1029 5y agoPretty sure that is wired up like an elevator close button. Never seen it make a difference and not for lack of trying.
- slater 5y agoMight wanna save some bandwidth with that 1.25meg yet small-in-visual-size portfolio.png, yikes! XD