[crac] RFR: 8350845: [CRaC] Support C/R engines in form of a library
Timofei Pushkin
tpushkin at openjdk.org
Fri Feb 28 06:39:19 UTC 2025
On Thu, 27 Feb 2025 13:30:11 GMT, Radim Vansa <rvansa at openjdk.org> wrote:
>> Adds support for C/R engines implemented in form of dynamic libraries.
>>
>> In the proposed API the engine controls the set of the configurable options — they are mainly passed by the user via the new `CRaCEngineOptions` VM option, but some may also be passed by the VM. Other VM and/or engine implementations may extend the API via "extensions".
>>
>> The JVM is supposed to know what configuration options and API extensions are supported by calling `can_configure` and `get_extension`.
>>
>> The user is supposed to know which options they can pass by asking the engine with `-XX:CRaCEngineOptions=help` (support for this is engine-dependent). Example of how this looks for bundled engines:
>>
>> $ java -XX:CRaCEngine=simengine -XX:CRaCEngineOptions=help -XX:CRaCCheckpointTo=cr -version
>>
>> crexec — pseudo-CRaC-engine used to relay data from JVM to a "real" engine implemented as an executable (instead of a library).
>> The engine executable is expected to have CRaC-CRIU-like CLI. Support of the options below also depends on the engine executable.
>>
>> Configuration options:
>> * keep_running=<true/false> (default: false) — keep the process running after the checkpoint or kill it.
>> * direct_map=<true/false> (default: false) — on restore, map process data directly from saved files. This may speedup the restore but the resulting process will not be the same as before the checkpoint.
>> * args=<string> (default: "") — free space-separated arguments passed directly to the engine executable, e.g. "--arg1 --arg2 --arg3".
>> * help — print this message.
>>
>> openjdk version "24-internal" 2025-03-18
>> OpenJDK Runtime Environment (slowdebug build 24-internal-adhoc.timpushkin.crac)
>> OpenJDK 64-Bit Server VM (slowdebug build 24-internal-adhoc.timpushkin.crac, mixed mode, sharing)
>>
>>
>> Notable related changes included in the patch:
>> - The ability to pass arguments to C/R engine was removed from `CRaCEngine` because it can now be implemented through `CRaCEngineOptions`. E.g. `-XX:CRaCEngine=criu,--verbose` is now `-XX:CRaCEngine=criu -XX:CRaCEngineOptions=args=--verbose`.
>> - `CRaCEngine` (as well as the new `CRaCEngineOptions`) VM Option is now not updated in the restored VM. This seems more correct because engine path and options will very likely differ on restore and on checkpoint, so it is not obvious how to combine them — just replacing won't always work. Until now the updates were ignored by the CRaC implementation anyway, so this should only be visible by inspecting ...
>
> src/hotspot/share/include/crlib/crlib.h line 67:
>
>> 65: bool (*can_configure)(crlib_conf_t *, const char *key);
>> 66: // Sets a configuration option. Returns true on success.
>> 67: // Key and value are valid C-strings.
>
> The docs should state that `value` does not have to be valid after the call (is copied if needed).
This is documented in the description of the whole API structure [here](https://github.com/openjdk/crac/pull/207/files/4076f28e380ec96fabd9ab218f21c7bb5d58ffb3#diff-2dae7c218d19b9a6accbd269da4b1944a7bcc94c6a9f54e6b84b82d247325d6fR49-R50)
> src/hotspot/share/include/crlib/crlib_restore_data.h line 42:
>
>> 40: // Called by the restoring application to pass data to the restored application.
>> 41: // 'data' must not be null, size must be greater than 0.
>> 42: // The engine may impose limits on the data size and return false if it is not accepted.
>
> Is the data copied in?
Yes, again, I decided to write this in a [single place](https://github.com/openjdk/crac/pull/207/files/4076f28e380ec96fabd9ab218f21c7bb5d58ffb3#diff-2dae7c218d19b9a6accbd269da4b1944a7bcc94c6a9f54e6b84b82d247325d6fR49-R50) for all of the API methods
-------------
PR Review Comment: https://git.openjdk.org/crac/pull/207#discussion_r1974880869
PR Review Comment: https://git.openjdk.org/crac/pull/207#discussion_r1974882029
More information about the crac-dev
mailing list