Java Performance

Author: Charlie Hunt, Binu John
4.3
All Stack Overflow 12
This Year Stack Overflow 1
This Month Stack Overflow 1

Java Performance

4.3

Review Date:

Comments

by anonymous   2017-08-20

There is the BOOK about java performance tuning:

-XX:SurvivorRatio=<n> should be used when you want to explicitly size survivor
spaces to manipulate object aging with the concurrent garbage collector, or to
manipulate object aging with the throughput garbage collector when adaptive sizing
is disabled using the command line option -XX:-UseAdaptiveSizePolicy.

So the -XX:SurvivorRatio is ignored unless you use -XX:-UseAdaptiveSizePolicy.

by anonymous   2017-08-20

Sizing Eden Space:

  • you need to compute Allocation Rate (see Advanced JVM Tuning) to determine the size of the your Eden Space.
  • also, Total Young Generation -Xmn should be from 1x to 1.5x of OldGen space occupancy after a full GC (as noted in Java Performance).

Sizing the Survivor Spaces:

  • you need to be watching Promotion Rate (again see Advanced JVM Tuning) so you do not make the FullGC too frequent by decreasing the Survivor/Eden space,
  • -XX:+PrintTenuringDistribution is essential, this will show you the Tenuring Ages,
  • -XX:SurvivorRatio=, -XX:TargetSurvivorRatio= and -XXMaxTenuringThreshold= will be needed to actually tune the Survivor Sizes.
  • See the Request for documentation of -XX:+PrintTenuringDistribution output for more info.
by anonymous   2017-08-20

There are multiple factors:

  • the type of garbage collector used;
  • collector configuration (e.g. the size of the various sub-heaps);
  • the size and frequency of memory allocations;
  • typical duration of object lifetime.

Java Performance by Hunt et al has some good material on optimizing Java GC for throughput and latency.

If you have a practical problem to solve, using a memory profiler on your program is often a good first step.

by anonymous   2017-08-20

PrintGCDetails - this option could be helpful. It prins information about every garbage collection.

[GC
[PSYoungGen: 99952K->14688K(109312K)]
422212K->341136K(764672K), 0.0631991 secs]
[Times: user=0.83 sys=0.00, real=0.06 secs]

Pprovides CPU usage and elapsed time information. The value to the right of user is the CPU time used by the garbage collection executing instructions outside the operating system. In this example, the garbage collector used 0.06 seconds of user CPU time. The value to the right of sys is the CPU time used by the operating system on behalf of the garbage collector. In this example, the garbage collector did not use any CPU time executing operating system instructions on behalf of the garbage collection. The value to the right of real is the elapsed wall clock time in seconds of the garbage collection. In this example, it took 0.06 seconds to complete the garbage collection.

Java Performance - good book, could be found in digital version. Contains a great article about measuring GC's impact.