416
A second, subordinate goal is to implement this commit behavior using a restricted,
JDK-internal API defined in class unsafe, allowing it to be reused by classes other than
MappedByteBuffer that may need to commit to persistent memory.
A final, related goal is to allow buffers mapped over persistent memory to be tracked
by the existing monitoring and management APIs.
It is already possible to map a persistent memory device file to a MappedByteBuffer
and commit writes using the current force() method, for example, using Intel’s
libpmem library as device driver or by calling out to libpmem as a native library.
However, with the current API, both those implementations provide a “sledgehammer”
solution. A force cannot discriminate between clean and dirty lines and requires a
system call or JNI call to implement each writeback. For both those reasons, the existing
capability fails to satisfy the efficiency requirement of this JEP.
The target OS/CPU platform combinations for this JEP are Linux/x64 and Linux/
AArch64. This restriction is imposed for two reasons. This feature will only work on OSes
that support the mmap system call MAP_SYNC flag, which allows synchronous mapping
of non-volatile memory. That is true of recent Linux releases. It will also only work on
CPUs that support cache line writeback under user space control. x64 and AArch64 both
provide instructions meeting this requirement.
Persistent Collections for Java (PCJ)
The Persistent Collections for Java library (PCJ) is an open source Java library being
developed by Intel for persistent memory programming. More information on PCJ,
including source code and sample code, is available on GitHub at https://github.com/
pmem/pcj.
At the time of writing this book, the PCJ library was still defined as a “pilot” project
and still in an experimental state. It is being made available now in the hope it is useful in
exploring the retrofit of existing Java code to use persistent memory as well as exploring
persistent Java programming in general.
The library offers a range of thread-safe persistent collection classes including arrays,
lists, and maps. It also offers persistent support for things like strings and primitive integer
and floating-point types. Developers can define their own persistent classes as well.
Instances of these persistent classes behave much like regular Java objects, but
their fields are stored in persistent memory. Like regular Java objects, their lifetime is
reachability-based; they are automatically garbage collected if there are no outstanding
Appendix d JAvA for persistent MeMory
Précédent

- 436/457

Suivant