Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (767)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java 9 GC  (Read 6990 times)
0 Members and 1 Guest are viewing this topic.
Offline princec

« JGO Spiffy Duke »


Medals: 1053
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Posted 2017-11-30 09:33:14 »

The new default collector in Java 9 is G1. This is bad, because G1 is hopelessly slow and everything runs like it's going through treacle.
Can anyone recommend a set of commandline magic parameters that mimics good ol' -Xincgc?

Cas Smiley

Offline ra4king

JGO Kernel


Medals: 508
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2017-11-30 10:59:02 »

Wtf it looks like they removed ALL garbage collectors other than G1?

Offline Spasi
« Reply #2 - Posted 2017-11-30 11:12:28 »

It would be useful to see a simple test program that demonstrates bad performance with G1GC. It certainly makes an interesting set of tradeoffs, but I haven't seen an application where enabling G1GC has such a pronounced impact on performance.

Cas, would you be able to post such a program?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 1053
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2017-11-30 11:24:24 »

Unfortunately not - all I can tell you is that it halves the framerate of Battledroid, and Eclipse seems to almost grind to a halt under Java 9.
(All 64-bit stuff, compressed OOPS)

Cas Smiley

Offline nsigma
« Reply #4 - Posted 2017-11-30 11:37:11 »

More good reasons to stick with the Java 8 LTS for a while!  Wink

Still, -Xincgc is kind of still there, if you can find documentation of what it actually translated to (got a note somewhere I'll see if I can dig out).  See https://docs.oracle.com/javase/9/gctuning/concurrent-mark-sweep-cms-collector.htm

I did read on the OpenJDK list a bunch of people (inc. Google and Red Hat people IIRC) talking about undeprecating and improving CMS - think Oracle are happy for that if they don't have to do anything.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline Spasi
« Reply #5 - Posted 2017-11-30 11:38:05 »

Could you describe what Battledroid's doing in the hot path? Are there many allocations? Are there many reference writes (e.g. a BVH getting updated)? This could be a matter of replacing OO code with something more data oriented.
Offline princec

« JGO Spiffy Duke »


Medals: 1053
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2017-11-30 12:41:27 »

@Spasi - it's been quite a long time since I really delved into it in any depth. The point being though that simply changing the garbage collector to -Xincgc doubled my framerate and the amount of garbage I was generating was already quite modest really. I did in the end even have to do something data oriented just to get my A* stuff working fast enough - instead of allocating and forgetting tens of thousands of A* "Nodes", I instead used large expanding arrays of int[] instead, effectively mostly managing my own memory... crap.

@Nsigma - thanks for the link (obviously, it's Googlable, but it's good to have it recorded here for posterity) - I guess I'll try each combo out in turn to find out what's best for my usage.

Cas Smiley

Offline h.pernpeintner

JGO Knight


Medals: 98



« Reply #7 - Posted 2017-11-30 13:41:38 »

Really annoying, that the said to be best Garbage Collector seems to perform worse for games.

@princecc: Would you mind take a look at your app with JMC and show us some metrics comparing the old state and the state after your latest changes? I found some comparisons in the internet, where G1 reduced the max pause time while keeping avg pause time equivalent to cms. Maybe you could post the gc times and avg pauses, created objects (screenshots) etc here, I'm just curious Smiley
Offline princec

« JGO Spiffy Duke »


Medals: 1053
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2017-11-30 13:45:24 »

Currently not really up to speed on the project, being diverted. I will return to it in the next few months but will likely mention the issue again around then, as it is vexing.
I am particularly keen to try the Shenandoah GC which as I understand it is available in the OpenJDK builds.

Cas Smiley

Offline h.pernpeintner

JGO Knight


Medals: 98



« Reply #9 - Posted 2017-11-30 14:53:24 »

I am particularly keen to try the Shenandoah GC which as I understand it is available in the OpenJDK builds.

That's interesting. I thought that Shenandoah is not suitable for normal applications, as the official description states:

This is not the one GC to rule them all. If you are running with a heap of 20GB or less or if you are running with a single core, you are probably better off with one of the current GC algorithms.

Looking forward to your results.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 1053
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #10 - Posted 2017-11-30 15:06:43 »

We're reasonably multithreaded in some places but the heap is definitely much smaller (under 1GB). What interested me was its consistency and high speed. Maybe the serial GC is all I really need though.

Cas Smiley

Offline Spasi
« Reply #11 - Posted 2017-11-30 15:15:10 »

If you're looking to test Shenandoah on Windows, looks like it's available in the 1.8.0.151 ojdkbuild.

That's interesting. I thought that Shenandoah is not suitable for normal applications

(Low-)pause-less GCs sacrifice maximum throughput for lower latency/pauses. Shenandoah has lower throughput than G1GC, but significantly lower pauses. A real-time game would actually value low latency much more than high throughput. Afaik, Shenandoah has been shown to perform well on small heaps too. Also note that Shenandoah increases object size (Brooks pointers).

Maybe the serial GC is all I really need though.

We have apps in production capped to 512MB with SerialGC and pauses are indeed small enough that it's a good tradeoff.
Offline nsigma
« Reply #12 - Posted 2017-11-30 16:49:35 »

@princec found an old launcher with this in it, which I think is similar/same as -incgc

1  
-J-XX:+UseConcMarkSweepGC -J-XX:+CMSIncrementalMode -J-XX:+CMSIncrementalPacing


However, it looks like while CMS is still there, they've also removed the incremental pacing flags.  Maybe just try the first argument?

We have apps in production capped to 512MB with SerialGC and pauses are indeed small enough that it's a good tradeoff.

That's a good point.  I've been using the SerialGC more recently.  If you can keep the heap from growing too much it's OK.  In Praxis LIVE I have the ability to split off pipelines into child VMs - I run audio in a separate VM with SerialGC and low heap size, but then I guess my "fps" is 10x what you need!  Wink

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline gouessej
« Reply #13 - Posted 2017-11-30 23:23:11 »

If you're looking to test Shenandoah on Windows, looks like it's available in the 1.8.0.151 ojdkbuild.
Why not using adoptopenjdk.net instead?

Julien Gouesse | Personal blog | Website | Jogamp
Offline Archive
« Reply #14 - Posted 2017-12-01 03:05:32 »

So glad I switched over to C/C++

Offline nsigma
« Reply #15 - Posted 2017-12-01 08:46:48 »

Why not using adoptopenjdk.net instead?

Is Shenandoah in there? Website claims not but didn't find release notes quickly.

Thanks @Archive for the drive-by trolling!  Tongue

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline princec

« JGO Spiffy Duke »


Medals: 1053
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #16 - Posted 2017-12-01 09:49:49 »

So glad I switched over to C/C++
I have to use C at work every day... it's like trying to build the Taj Mahal out of matchsticks.

Cas Smiley

Offline ShchAlexander
« Reply #17 - Posted 2018-08-10 16:30:39 »

Is it still true about Java 9 GC? or it was improved since post creation time?
Offline nsigma
« Reply #18 - Posted 2018-08-10 18:48:48 »

Is it still true about Java 9 GC? or it was improved since post creation time?

Not sure I'd be worrying about anything other than Java 11 GC.  But it remains to be seen if that is any better.

Now, interestingly since this thread was active, I had someone contribute a small patch to my Java JACK bindings (a native real-time callback-based audio server).  I haven't tried Shenandoah myself, but they were getting reliable ~1ms latency with no xruns (missed deadlines) using the bindings with Shenandoah.  If that proves to be the case in general performance, it could be the ideal GC for games, despite what is quoted above.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline FabulousFellini
« Reply #19 - Posted 2018-08-10 19:11:03 »


Not sure I'd be worrying about anything other than Java 11 GC.  But it remains to be seen if that is any better.

Now, interestingly since this thread was active, I had someone contribute a small patch to my Java JACK bindings (a native real-time callback-based audio server).  I haven't tried Shenandoah myself, but they were getting reliable sub-1ms latency with no xruns (missed deadlines) using the bindings with Shenandoah.  If that proves to be the case in general performance, it could be the ideal GC for games, despite what is quoted above.

Wow.  I have no idea what you just said.  Lol.  I have a lot to learn!

-FabulousFellini
www.fabulousfellini.com
Offline nsigma
« Reply #20 - Posted 2018-08-11 09:44:50 »

Wow.  I have no idea what you just said.  Lol.  I have a lot to learn!

Sorry!  Grin  To try and say it in a simpler way, if you're doing any (soft) real-time task your code has a deadline to meet.  If you're doing a 60 frames per second game, to not miss a frame your code has to complete what it's doing each frame in lower than (1/60 sec) ~16ms.  If the GC kicks in then the time it takes and the time your code takes must be lower than ~16ms.  In fact, in a multi-process system you almost certainly can't take the full 16ms.

Audio with something like JACK processes in a callback into Java at maybe more like 300 or 600 frames per second.  And missed deadlines are a lot more noticeable in audio.  Therefore you're looking at a situation where your code (and possibly GC) has to guarantee to run in less than a few ms.  If Shenandoah is working well for the higher framerates of audio, then it should also work well for a 60fps game.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline KaiHH

JGO Kernel


Medals: 587



« Reply #21 - Posted 2018-08-11 10:07:49 »

I'd say the problem is that there is hardly anyone at Oracle or the JCP that cares about games written in Java, which:
1. have not 128GB of server machine memory footprint but rather 1-2GB
2. value consistent low-latency GC more than high throughput

Java EE (sorry, I meant Jakarta EE) application servers certainly don't care whether GC takes 10ms or 50ms at times. There are certainly use-cases for 2. with even lower memory footprints in the tens or hundreds of megabytes for embedded systems, but that's where dedicated commercial real-time JVMs from for example Aonix/Perc/PTC come into play. This is probably not something where Oracle or the OpenJDK wants to excel in.
Offline nsigma
« Reply #22 - Posted 2018-08-11 13:03:32 »

This is probably not something where Oracle or the OpenJDK wants to excel in.

Not sure about Oracle, although the web is changing!  Maybe them donating (ditching) EE says something?

But I'm sure some OpenJDK partners have an interest in 2.  Which makes me think.  OpenJ9 with Metronome GC might be worth some experiments.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1258 views)
2018-06-10 19:43:48

EgonOlsen (1126 views)
2018-06-10 19:43:44

EgonOlsen (864 views)
2018-06-10 19:43:20

DesertCoockie (1273 views)
2018-05-13 18:23:11

nelsongames (1105 views)
2018-04-24 18:15:36

nelsongames (1336 views)
2018-04-24 18:14:32

ivj94 (2076 views)
2018-03-24 14:47:39

ivj94 (1229 views)
2018-03-24 14:46:31

ivj94 (2171 views)
2018-03-24 14:43:53

Solater (795 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!