[crac] RFR: 8376959: [CRaC] Turn simengine into shared library [v8]
Timofei Pushkin
tpushkin at openjdk.org
Fri Feb 6 08:45:04 UTC 2026
On Wed, 4 Feb 2026 15:35:25 GMT, Radim Vansa <rvansa at openjdk.org> wrote:
>> Right now `simengine` is implemented as an executable, invoked through `libcrexec` that implements the C/R API. Since the programmatic C/R API should be the main interface, any exec API is redundant; let's turn `simengine` into shared (dynamic) library implementing the API on its own.
>>
>> The `pauseengine` does not need to exist on its own; this can be only an option `pause=true` for `simengine`. The implementation is Linux only (and it is out of scope to fill in a non-Linux implementation - the `pause` option can be just excluded in non-Linux `libsimengine`).
>>
>> We expect to turn `libcrexec` + `criuengine` into `libcriuengine` in a follow up (not as part of this issue).
>
> Radim Vansa has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains eight commits:
>
> - Merge branch 'crac' into simengine_separation
> - Fix tests on non-Linux
> - Try fix Windows build
> - Address review comments
> - Fixup
> - Fixups
> - Implement static build & other platforms
> - JDK-8376959: [CRaC] Turn simengine into shared library
Please don't forget https://github.com/openjdk/crac/pull/289#discussion_r2758659955
src/hotspot/share/runtime/crac_engine.cpp line 250:
> 248: return nullptr;
> 249: }
> 250: }
Should be under `#ifdef LINUX`, `is_pauseengine` itself could be as well
src/java.base/share/native/libcrcommon/crcommon.cpp line 27:
> 25: #include "crcommon.hpp"
> 26:
> 27: #include "image_constraints.hpp"
`crlib*` headers should be included since they are used directly
src/java.base/share/native/libcrcommon/crcommon.cpp line 63:
> 61:
> 62: JNIEXPORT bool init_conf(struct crlib_conf* conf, const char* prefix) {
> 63: log_prefix = prefix;
Indent should be 2, in `destroy_conf` as well
src/java.base/share/native/libcrcommon/crcommon.hpp line 74:
> 72: void *image_constraints;
> 73: void *image_score;
> 74: };
Since we want to use the C layer a more conventional way seems to be to move this definition to `crcommon.cpp` (it can even become a normal class with a constructor/destructor) and use composition instead of inheritance (engine classes would be `struct crlib_conf`s themselves, `bool init_conf(conf_t* conf, ...)` would become `conf_t* create_conf(...)`). These fields are not used directly anywhere except `crcommon.cpp` anyway.
Otherwise the fields can at least become their actual types to remove the casts in `crcommon.cpp`.
src/java.base/share/native/libcrcommon/crcommon.hpp line 83:
> 81:
> 82: extern "C" {
> 83: extern CRCOMMON_API const char* log_prefix;
Nitpick: this looks like it should be a part of `crlib_conf_t`. `LOG` can accept `conf` as parameter — does not seem too bulky. If the conf will be an opaque type then ` const char* log_prefix(const crlib_conf*)` will also be needed.
src/java.base/share/native/libcrcommon/crcommon.hpp line 85:
> 83: extern CRCOMMON_API const char* log_prefix;
> 84:
> 85: extern CRCOMMON_API bool init_conf(struct crlib_conf* conf, const char* log_prefix);
`crlib_conf_t` can be used instead of `struct crlib_conf`. It is not only in this file.
-------------
PR Review: https://git.openjdk.org/crac/pull/289#pullrequestreview-3757660401
PR Review Comment: https://git.openjdk.org/crac/pull/289#discussion_r2769626562
PR Review Comment: https://git.openjdk.org/crac/pull/289#discussion_r2772944143
PR Review Comment: https://git.openjdk.org/crac/pull/289#discussion_r2772899159
PR Review Comment: https://git.openjdk.org/crac/pull/289#discussion_r2772861394
PR Review Comment: https://git.openjdk.org/crac/pull/289#discussion_r2772891014
PR Review Comment: https://git.openjdk.org/crac/pull/289#discussion_r2772894519
More information about the crac-dev
mailing list