How can we overcome the GC pauses?

Started by Jakes, January 25, 2020, 06:15:27 AM

Previous topic - Next topic

Jakes

I know this might not be the best place to start this but, as this is something that requires a top performance execution, it could have something to do.

After some digging, tuning and playing around with the GC arguments to try to get some good configurations I ended up not having any success at solving its execution pauses.

We all know that the "Stop-the-world" issue while garbage collecting is real, but is there any way to overcome it in an elegant way? I mean, how do anyone here sets up their specs in order to have a nice experience without any lag or freezing every once in a while?

currently, this is what I'm using:

-XX:MaxGCPauseMillis=10 -XX:ParallelGCThreads=4 -Xmx1072M -Xms1072M -XX:+UseParallelGC -XX:NewRatio=4

but, even this, it will fill up the heap memory in a matter of minutes, and once its there, there will be a major sweep that will be noticeable to the simulation and the player.

Any tips or hints will be highly appreciated

EgonOlsen

I never really played around with GC settings and I never noticed it causing any slowdowns or hickups at least during the last decade. On earlier Android versions, this was a problem but on the desktop...!? Are you sure it's the GC that causes the problem?

Jakes

Yes, I've been using a profiler to check on what's causing the pauses, and it turned out to be the major collections of the GC. Every time a major swipe occured a short pause of half second or so would happen. This is most noticable on low-end pcs.

The pause the world GC is a thing even today, but after some investigation it seems that there's some set of solutions fot this that I will post here after I had my tests done.

EgonOlsen

Strange. I've never ever encountered a gc pause of half a second unless you are close to run out of memory. Not even on heavy loaded servers with hundreds of threads running in parallel. What is a low-end pc in this context?

Jakes

By reading this thread https://stackoverflow.com/questions/16695874/why-does-the-jvm-full-gc-need-to-stop-the-world its easy to understand why it's normal to have short pauses on the threads in order to collect older data.

and this one https://plumbr.io/blog/garbage-collection/minor-gc-vs-major-gc-vs-full-gc to understand the differences.

And yes, I'm a bit of a performance geek, and want to try to give my best on any project, mosly because I'm aiming for low-end machines as well, and by low-end I mean 800s/900s Nvidia GPUs and dual cores CPUs, as well as older i5s and i7s.