[crac] RFR: Persist memory in-JVM [v7]
Radim Vansa
rvansa at openjdk.org
Tue Oct 3 07:17:12 UTC 2023
> This is a WIP for persisting various portions of JVM memory from within the process, rather than leaving that up to C/R engine (such as CRIU). In the future this will enable us to optimize loading (theoretically leading to faster startup), compress and encrypt the data.
>
> At this moment the implementation of persisting thread stacks is in proof-of-concept shape, ~especially waking up the primordial thread includes some hacks. This could be improved by using a custom (global, ideally robust) futex instead of the internal futex used by `pthread_join`.~ Fix already implemented.
>
> ~One of the concerns related to thread stacks is rseq used by glibc; without disabling this CRIU would attempt to 'fix' the rseqs (see `fixup_thread_rseq`) and touch the unmapped memory. CRIU uses special ptrace commands to check the status; I am not aware if it is possible to access this information from within the process using any public API.~ Solved. The JVM forks and the child ptraces JVM, recording the rseq info. Once we have the we can unregister the rseq before checkpoint and register it afterwards (here we have the advantage that we know the threads won't be in any critical section as we're in a safepoint).
> ~Currently this works with `/proc/sys/kernel/yama/ptrace_scope` set to `0`; we should make it work with `1` (default), too.~ Fixed.
>
> Regarding persistence implementation, currently we store the memory in multiple files; first block (page-size aligned) contains some validation data and index of memory address - file offsets. The way this is implemented requires the size of index to be known before dumping memory. It might be more convenient (and portable for e.g. network-based storage) to use single file, and either keep the index in the 'fundamental' memory (C heap), put it at the end of file or to another index file.
Radim Vansa has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 37 commits:
- Merge remote-tracking branch 'origin/crac' into persist_memory
- Fix reloading memory when checkpoint fails
- Fix compilation on different OSes
- Improve aarch64 assembly
- Move MemoryPersister impl to own file
- Merge branch 'crac' into persist_memory
- Backport of API from future changes for other persistent memory features
- Another assembly fix
- Don't fork when we're not unregistering rseq
- Fix assembly loop
- ... and 27 more: https://git.openjdk.org/crac/compare/4d1e7b9d...fea0155a
-------------
Changes: https://git.openjdk.org/crac/pull/95/files
Webrev: https://webrevs.openjdk.org/?repo=crac&pr=95&range=06
Stats: 1195 lines in 33 files changed: 1164 ins; 12 del; 19 mod
Patch: https://git.openjdk.org/crac/pull/95.diff
Fetch: git fetch https://git.openjdk.org/crac.git pull/95/head:pull/95
PR: https://git.openjdk.org/crac/pull/95
More information about the crac-dev
mailing list