Why is the Java G1 gc spending so much time scanning RS?

后端 未结 1 1524
遥遥无期
遥遥无期 2021-01-05 15:52

I\'m currently evaluating the G1 garbage collector and how it performs for our application. Looking at the gc-log, I noticed a lot of collections have very long \"Scan RS\"

相关标签:
1条回答
  • 2021-01-05 16:23

    Let's see.

    1 - First clues

    It looks like your GC was configured to use 4 threads (or you have 4 vCPU, but it is unlikely given the size of the heap). It is quite low for a 128GB heap, I was expecting more.

    The GC events seems to happen at 25+ seconds interval. However, the log extract you gave do not mention the number of regions that were processed.

    => By any chance, did you specify pause time goals to G1GC (-XX:MaxGCPauseMillis=N) ?

    2 - Long Scan RSet time

    "Scan RSet" means the time the GC spent in scanning the Remembered Sets. Remembered Set of a region contains cards that correspond to the references pointing into that region. This phase scans those cards looking for the references pointing into all the regions of the collection set.

    So here, we have one more question :

    => How many regions were processed during that particular collection (i.e. how big is the CSet)

    3 - Long Object Copy time

    The copy time, as the name suggest, is the time spend by each worker thread copying live objects from the regions in the Collection Set to the other regions.

    Such long copy time can suggest that a lot of regions were processed, and that you may want to reduce that number. It could also suggest swapping, but this is very unlikely given your user/real values at the end of the log.

    4 - Now what to do

    You should check in the GC log the number of regions that were processed. Correlate this number with your region size and deduce the amount of memory that was scanned.

    You can then set a smaller pause time goal (for instance, to 500ms using -XX:MaxGCPauseMillis=500). This will

    • increase the number of GC events,
    • reduce the amount of freed memory per GC cycle
    • reduce the STW pauses during YGC

    Hope that helps !

    Sources :

    • https://blogs.oracle.com/poonam/entry/understanding_g1_gc_logs
    • http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/G1GettingStarted/index.html
    • http://jvm-options.tech.xebia.fr/
    0 讨论(0)
提交回复
热议问题