[crac] RFR: Portable C/R

Timofei Pushkin duke at openjdk.org
Tue Jun 4 17:04:31 UTC 2024


Implements a proof-of-concept "portable mode" for CRaC: a checkpoint-restore mechanism that does not rely on platform-dependent tools like CRIU instead saving VM state in terms of the Java specification (with some HotSpot specifics) — this allows to restore the saved state on machines with different CPU architecture and OS. A demo is available [here](https://github.com/TimPushkin/portable-crac-demo).

Expected downsides compared to the traditional CRaC are restrictions on platform-dependent code usage (e.g. at the moment of checkpoint no native methods can be executing, off-heap memory obtained via `sun.misc.Unsafe` should be released) and somewhat slower restoration speeds (because platform-dependent state, including JIT-compiled code, should be re-created). In the future, Project Leyden may help with the latter.

The mechanism is implemented as an internal part of HotSpot, it gets activated when an empty `CREngine` VM option is passed (i.e. `-XX:CREngine=""`, this is a temporary solution). Main implementation details are described in [this doc](https://github.com/TimPushkin/crac/blob/portable-cr/trimmed/doc/portable-cr.md).

Since this is a proof-of-concept implementation, it currently lacks some important features. E.g. at the moment some early-initialized classes are not restored, most of JDK classes have not yet been properly adapted, checkpointing via `jcmd` is not fully supported, additional tests and optimizations are needed.

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

Commit messages:
 - Add temporary runner for portable CRaC tests
 - Add monitors support to portable C/R
 - Fix some crac/fileDescriptors tests failing because of NativeThread resource
 - Add portable CRaC support into more JDK classes
 - Use jdk.internal.crac in adapted classes
 - Fix dumping of interned j.l.String
 - Pre-initialize problematic MethodType-related classes
 - Fix resolution error restoration crash
 - Fix class loaders not being fully registered when re-creating non-strong hidden classes
 - Remove false assertion on resolved method enties' bytecodes
 - ... and 84 more: https://git.openjdk.org/crac/compare/7d03b259...525d2a8f

Changes: https://git.openjdk.org/crac/pull/155/files
  Webrev: https://webrevs.openjdk.org/?repo=crac&pr=155&range=00
  Stats: 14433 lines in 159 files changed: 13890 ins; 287 del; 256 mod
  Patch: https://git.openjdk.org/crac/pull/155.diff
  Fetch: git fetch https://git.openjdk.org/crac.git pull/155/head:pull/155

PR: https://git.openjdk.org/crac/pull/155


More information about the crac-dev mailing list