2

I have some questions about G1 GC, I know if I set -XX:MaxGCPauseMillis too small,G1 has very few regions recycled each time.GC garbage collection speed can't catch up with user thread garbage generation speed, could cause gc so frequency that efficiency is too bad.

I want to know if I set -XX:MaxGCPauseMills too big what will happen? Isn't there a lot of regions to recycle every time?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Colin
  • 21
  • 3
  • 2
    What is your concern? That a garbage collection could recycle “too many” regions? – Holger Apr 20 '21 at 07:14
  • I'm sorry my English level is poo.I mean, if I set -XX:MaxGCPauseMills too large, what's the disadvantage? Besides the pause time, isn't G1 GC able to collect more regions each time? Throughput will also increase. – Colin Apr 20 '21 at 07:35
  • 1
    There is no value that is “too large”. There is a natural limit on the pause, e.g. when the entire heap has been compacted. But it won’t go that far, as there are other heuristics (and options) stopping it from wasting too much effort for too little effect. There is no simple relationship between this pause time and the throughput. The general assumption is that beyond certain thresholds, there is no benefit in larger pauses at all. That’s why the options have these defaults preventing the garbage collector from doing too much. – Holger Apr 20 '21 at 07:46
  • I think I understand.It means that setting its value too large doesn't work. The internal setting of the virtual machine won't make it pause for too long, right? – Colin Apr 20 '21 at 08:38
  • 1
    Depending on the application, large values may degrade performance, but it should never become catastrophic. It would rather converge to the behavior of the concurrent collectors not having a pause time goal option. – Holger Apr 20 '21 at 08:59
  • @Holger is right, both pause time and throughput is taken into consideration when decided the number of regions, there is even a comment to denote that in source code [here](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/gc/shared/adaptiveSizePolicy.hpp#L168). The entire truth is in those `adaptiveSizePolicy.cpp/hpp`. In general, if you set `XX:MaxGCPauseMillis` to be too small, there will be many short collections and if you make it big there will longer collections, but more apart from each other. It is a thin line – Eugene Apr 20 '21 at 21:43
  • @Eugene this link is great! – Colin Apr 21 '21 at 01:09

0 Answers0