RFR: 8321815: Shenandoah: gc state should be synchronized to java threads only once per safepoint

William Kemper wkemper at openjdk.org
Fri Dec 15 17:29:38 UTC 2023


On Thu, 14 Dec 2023 19:14:07 GMT, William Kemper <wkemper at openjdk.org> wrote:

> Presently, every change to the gc change is distributed to all java threads. The gc state is only changed on safepoints. For applications with a very large number of java threads this may increase time on the safepoint. It would be better to synchronize the gc state only once per safepoint.

This instrumentation isn't included in this PR, but it shows how often GC state changes in a typical cycle:

[40.118s][31676][info ][gc,start    ] GC(1) Pause Init Mark (unload classes)
[40.118s][31676][info ][gc          ] GC(1) GC state = 22
[40.118s][31676][info ][gc          ] GC(1) Pause Init Mark (unload classes) 0.119ms
[41.646s][31676][info ][gc,start    ] GC(1) Pause Final Mark (unload classes)
[41.646s][31676][info ][gc          ] GC(1) GC state = 0
[41.646s][31676][info ][gc          ] GC(1) GC state = 10
[41.648s][31676][info ][gc          ] GC(1) GC state = 14
[41.648s][31676][info ][gc          ] GC(1) GC state = 15
[41.648s][31676][info ][gc          ] GC(1) Pause Final Mark (unload classes) 2.324ms
[42.774s][31676][info ][gc,start    ] GC(1) Pause Init Update Refs
[42.774s][31676][info ][gc          ] GC(1) GC state = 11
[42.774s][31676][info ][gc          ] GC(1) GC state = 1
[42.774s][31676][info ][gc          ] GC(1) GC state = 9
[42.774s][31676][info ][gc          ] GC(1) Pause Init Update Refs 0.108ms
[43.040s][31676][info ][gc,start    ] GC(1) Pause Final Update Refs
[43.040s][31676][info ][gc          ] GC(1) GC state = 1
[43.040s][31676][info ][gc          ] GC(1) GC state = 0
[43.040s][31676][info ][gc          ] GC(1) Pause Final Update Refs 0.162ms

And for some degenerated cycles, many of these changes may happen on the same safepoint:

[60.839s][31676][info ][gc,start       ] GC(17) Pause Degenerated GC (Mark)
[61.417s][31676][info ][gc             ] GC(17) GC state = 0
[62.291s][31676][info ][gc             ] GC(17) GC state = 4
[62.291s][31676][info ][gc             ] GC(17) GC state = 5
[62.309s][31676][info ][gc             ] GC(17) GC state = 1
[62.309s][31676][info ][gc             ] GC(17) GC state = 1
[62.309s][31676][info ][gc             ] GC(17) GC state = 9
[63.372s][31676][info ][gc             ] GC(17) GC state = 1
[63.372s][31676][info ][gc             ] GC(17) GC state = 0
[63.373s][31676][info ][gc             ] GC(17) Pause Degenerated GC (Mark) 31103M->24719M(32768M) 2534.356ms

I can add the assertions you described in the prologue and epilogue methods. For what it's worth, changes to the gc state already assert the changes occur on a safepoint.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17112#issuecomment-1858231413


More information about the hotspot-gc-dev mailing list