mors
mors

Reputation: 507

Give more CPU time to GC in java?

I have an java application that uses as much CPU as it can and, with it, a lot of memory (up to 80Gb).

I am optimizing the GC for that app and I want to tell the JVM to use a given percentage of time (60%) to the GC, else the amount of time the machine is not in GC is processing and allocating more memory.

I wanted to confirm that the -XX:CMSIncrementalDutyCycle=60 parameter is the thing I'm looking for and if there is any other parameters to give more power to the GC (I've already seen the CMSIncrementalPacing and CMSIncrementalDutyCycleMin)

Thanks a bunch!

Upvotes: 5

Views: 2354

Answers (3)

Alexey Ragozin
Alexey Ragozin

Reputation: 8379

First, CMSIncreamentalDutyCycle affects on incremental CMS algoright (which should be enabled by -XX:+CMSIncrementalMode). Incremental mode is bad for your task any way.

Second, you can limit number of CPU core consumed by GC tasks.

  • -XX:ParallelGCThreads=N sets number of core for Stop-the-World phases
  • -XX:ConcGCThreads=N sets number of core for concurrent tasks (only for CMS)

You can find more GC related options here.

Upvotes: 1

Aleš
Aleš

Reputation: 9028

You cannot set a ceiling for the CPU usage during the GC collections.

The CMSIncrementalDutyCycle is used to set the time between minor collections (see [1]), so you can control how often the GC runs and thus indirectly the CPU usage. But, there is no parameter that would allow you to control the CPU usage directly.

Upvotes: 1

Amir Afghani
Amir Afghani

Reputation: 38521

I wanted to confirm that the XX:CMSIncrementalDutyCycle=60 parameter is the thig I'm looking for and if there is any other parameters to give more power to the GC (I've already seen the CMSIncrementalPacing and CMSIncrementalDutyCycleMin)

No, you are wrong. This flag will not control what percent of available CPU will be alloted to the JVM's GC. The documentation states:

-XX:CMSIncrementalDutyCycle=<N> default: 50

This is the percentage (0-100) of time between minor collections that the concurrent collector is allowed to run. If CMSIncrementalPacing is enabled, then this is just the initial value.

So, assuming that you are using the CMS collector (-XX:+UseConcMarkSweepGC), then the flag above controls the percentage of time the CMS is allowed to execute between minor GC collections.

There is no flag that allows you to directly control the amount of time the GC thread executes.

Upvotes: 1

Related Questions