Peformance tuning letter

最後はゲームプログラマが始めたスレッドですが、こんなアドバイスがありました。 「だいたいの場合、すべてのガベージがかなり頻繁に削除され、古い世代に送られるものがほとんどないように、若い世代の回収機構をチューニングできなくてはいけません」 問題は、いったいどうやってそんなことをするのか、ということです。 私の経験では、生存オブジェクト用のスペースを増やすのが一番いいようです。 Eden と survivor spaces はすべて若い空間から取り分けられていて、survivor space の大きさを増やせば Eden の大きさは小さくなります。 Eden の全体的サイズを減らすと GC が頻繁に起きるようになります。 survivor spaces を大きくするとオブジェクトは(GC のコストがずっと低い)若い世代に残るようになります。 他のすべてのパフォーマンスチューニングのアドバイスもそうですが、効果は必ずしもあるとは限りません。

-XX:SurvivorRatio=n は -XX:+UseConcMarkSweepGC が有効でないと効かない?

linux 1.5.0_10-b03
SurvivorRatio指定なし

 -Xms2560m -Xmx2560m -XX:NewSize=512m 
 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC

{Heap before gc invocations=1:
 par new generation   total 523840K, used 523392K [0x15000000, 0x35000000, 0x35000000)
  eden space 523392K, 100% used [0x15000000, 0x34f20000, 0x34f20000)
  from space 448K,   0% used [0x34f90000, 0x34f90000, 0x35000000)
  to   space 448K,   0% used [0x34f20000, 0x34f20000, 0x34f90000)
 concurrent mark-sweep generation total 2097152K, used 21669K [0x35000000, 0xb5000000, 0xb
5000000)
 concurrent-mark-sweep perm gen total 16384K, used 10860K [0xb5000000, 0xb6000000, 0xb9000
000)
[ParNew 545061K->90196K(2620992K), 0.5306093 secs]
Heap after gc invocations=2:
 par new generation   total 523840K, used 0K [0x15000000, 0x35000000, 0x35000000)
  eden space 523392K,   0% used [0x15000000, 0x15000000, 0x34f20000)
  from space 448K,   0% used [0x34f20000, 0x34f20000, 0x34f90000)
  to   space 448K,   0% used [0x34f90000, 0x34f90000, 0x35000000)
 concurrent mark-sweep generation total 2097152K, used 90196K [0x35000000, 0xb5000000, 0xb
5000000)
 concurrent-mark-sweep perm gen total 16384K, used 10860K [0xb5000000, 0xb6000000, 0xb9000
000)
}

SurvivorRatio指定あり

 -Xms2560m -Xmx2560m -XX:NewSize=512m -XX:SurvivorRatio=8
 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC

{Heap before gc invocations=0:
 par new generation   total 471872K, used 419456K [0x0d1f0000, 0x2d1f0000, 0x2d1f0000)
  eden space 419456K, 100% used [0x0d1f0000, 0x26b90000, 0x26b90000)
  from space 52416K,   0% used [0x26b90000, 0x26b90000, 0x29ec0000)
  to   space 52416K,   0% used [0x29ec0000, 0x29ec0000, 0x2d1f0000)
 concurrent mark-sweep generation total 2097152K, used 0K [0x2d1f0000, 0xad1f0000, 0xad1f0
000)
 concurrent-mark-sweep perm gen total 16384K, used 10678K [0xad1f0000, 0xae1f0000, 0xb11f0
000)
[ParNew 419456K->32632K(2569024K), 0.2045250 secs]
Heap after gc invocations=1:
 par new generation   total 471872K, used 32632K [0x0d1f0000, 0x2d1f0000, 0x2d1f0000)

  eden space 419456K,   0% used [0x0d1f0000, 0x0d1f0000, 0x26b90000)
  from space 52416K,  62% used [0x29ec0000, 0x2be9e2c8, 0x2d1f0000)
  to   space 52416K,   0% used [0x26b90000, 0x26b90000, 0x29ec0000)
 concurrent mark-sweep generation total 2097152K, used 0K [0x2d1f0000, 0xad1f0000, 0xad1f0
000)
 concurrent-mark-sweep perm gen total 16384K, used 10678K [0xad1f0000, 0xae1f0000, 0xb11f0
000)
}