Cross-posting RFR from CRaC Project. The change touches Reference class, so I would be glad to receive any feedback from core-libs-dev.
In CRaC project, java code participates in the preparation of the platform state that can be safely stored to the image. The image can be attempted at any time, so the image may capture unprocessed References. Recently I found cases when objects became unreachable during preparation for the checkpoint, and their associated clean-up actions to close external resources (which we don't allow open when the image is stored). So it's become necessary to ensure as many References as possible are processed before the image is created. As a nice additional feature, restored java instances won't start with the same Reference processing. With the change, the image is not created until VM's queue of pending j.l.References are drained, and then, as an example, each j.l.ref.Cleaner queue is drained, only then the VM is called to prepare the image. More Reference handling threads will be changed like Cleaner's ones. I'm looking for possible problems or general comments about this approach. Thanks, Anton On 1/31/22 14:51, Anton Kozlov wrote:
At the time of checkpoint, a set of References may need handling. This change ensures no References pending in ReferenceHandler and in Cleaners. System.gc() is a best effort attempt to make GC to look for References. Default VM flags (-DisableExplicitGC, -ExplicitGCInvokesConcurrent) should not block the call, but additional investigation is needed to make sure GC found all references. ------------- Commit messages: - Ensure empty Reference Handler and Cleaners queues Changes: https://git.openjdk.java.net/crac/pull/13/files Webrev: https://webrevs.openjdk.java.net/?repo=crac&pr=13&range=00 Stats: 126 lines in 5 files changed: 124 ins; 0 del; 2 mod Patch: https://git.openjdk.java.net/crac/pull/13.diff Fetch: git fetch https://git.openjdk.java.net/crac pull/13/head:pull/13 PR: https://git.openjdk.java.net/crac/pull/13
