JDK-8171181 : JEP 316: Heap Allocation on Alternative Memory Devices
  • Type: JEP
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P3
  • Status: Closed
  • Resolution: Delivered
  • Fix Versions: 10
  • Submitted: 2016-12-13
  • Updated: 2020-10-02
  • Resolved: 2018-03-20
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8190308 :  
Description
Summary
-------

Enable the HotSpot VM to allocate the Java object heap on an alternative memory device, such as an NV-DIMM, specified by the user.

Motivation
----------

With the availability of cheap NV-DIMM memory, future systems may be equipped with heterogeneous memory architectures. One example of such technology is Intel's 3D XPoint. Such an architecture, in addition to DRAM, will have one or more types of non-DRAM memory with different characteristics.

This JEP targets alternative memory devices that have the same semantics as DRAM, including the semantics of atomic operations, and can therefore be used instead of DRAM for the object heap without any change to existing application code. All other memory structures such as the code heap, metaspace, thread stacks, etc., will continue to reside in DRAM. 

Some use cases for this proposal are:

1. In multi-JVM deployments some JVMs such as daemons, services, etc., have lower priority than others. NV-DIMMs would potentially have higher access latency compared to DRAM. Low-priority processes can use NV-DIMM memory for the heap, allowing high-priority processes to use more DRAM.

2. Applications such as big data and in-memory databases have an ever-increasing demand for memory. Such applications could use NV-DIMM for the heap since NV-DIMMs would potentially have a larger capacity, at lower cost, compared to DRAM.

Description
-----------

Some operating systems already expose non-DRAM memory through the file system. Examples are [NTFS DAX mode][ntfs-dax] and [ext4 DAX][ext4-dax]. Memory-mapped files in these file systems bypass the page cache and provide a direct mapping of virtual memory to the physical memory on the device.

[ntfs-dax]: https://channel9.msdn.com/events/build/2016/p470
[ext4-dax]: https://lwn.net/Articles/618064

To allocate the heap in such memory we can add a new option, `-XX:AllocateHeapAt=<path>`. This option would take a path to the file system and use memory mapping to achieve the desired result of allocating the object heap on the memory device. The JEP does not intend to share a non-volatile region between multiple running JVMs or re-use the same region for further invocations of the JVM.

The existing heap related flags such as `-Xmx`, `-Xms`, etc., and garbage-collection related flags would continue to work as before.

To ensure application security the implementation must ensure that file(s) created in the file system are:

1. Protected by correct permissions, to prevent other users from accessing it.
2. Removed when the application terminates, in any possible scenario.

Testing
-------

Testing will not necessarily require any special memory; it can be performed on in-memory file systems such as ramfs or tmpfs.

Comments
Requesting TOIs - Format, duration, and content to be determined at a later date.
20-12-2017

Kishor has modified the JEP text according to Brian's comment above.
23-11-2017

NV region is not shared by multiple VMs. Also, the lifetime is for the single JVM. The file is protected by correct permission so that other processes would not be able to access it.
21-11-2017

@Vivek: Thanks for the clarification. Can you please state this in the JEP text, since it is a very easy confusion to make to assume that we might be taking advantage of the sharability or nonvolatility of the NVRAM in this project?
21-11-2017

I understand that this JEP is not intended to support shared access to the same NV region from multiple running JVMs. Could you clarify that this is the case in the JEP? (Do we use file locking to prevent this?) Similarly, I would assume you're not trying to support resuming a previous JVM run even though the heap may be in NV memory. Again, could you clarify that this is for use by a single JVM invocation lifetime?
20-11-2017

Set the Fix version to 10
20-11-2017

[~kkharbas] You've moved this to Proposed to Target, but the Fix Version field is empty. Please fill in that field to indicate the release you intend to target.
20-11-2017

@Mark: Looks good. Thanks.
16-11-2017

[~kkharbas] I've edited the text to tighten the wording and remove information that's not necessary. If this looks good to you then assign it back to me and I'll move it to Candidate.
15-11-2017

Latest webrevs are in the implementation sub-task
13-11-2017

@Ioi : Thanks for the sanity test. I have verified working of CDS with the command line flags you suggested.
03-11-2017

I have a new version of this patch at http://cr.openjdk.java.net/~kkharbas/8171181/webrev.06/ This version has been tested on Windows, Linux, Solaris and Mac OS. I could not get access to AIX for testing. I used tmpfs to test the functionality. Cases that were tested were. 1. Allocation of heap using file mapping when ���XX:HeapDir= option is used. 2. Creation of nameless temporary file for Heap allocation which prevents access to file using its name. 3. Correct deletion and freeing up of space allocated for file under different exit conditions. 4. Error handling when path specified is not present, heap size is more than size of file system, etc.
21-07-2017

@ Mikael : I have assigned the JEP to you. I request you to move it to endorsed stage if you see it ready for it.
13-03-2017

Changed the assignee to Mikael Vidstedt. Mikael, could you review the JEP and endorse it later. Thanks
16-02-2017

A sanity test for compatibility of CDS with NV-DIMM would be: java -Xshare:dump -XX:HeapDir=/some/file -XX:+PrintSharedSpaces java -Xshare:on -XX:HeapDir=/some/file -XX:+PrintSharedSpaces -version If CDS is successfully used, you should see the word "sharing" in the output, like: OpenJDK 64-Bit Server VM (build 9-ea+149, mixed mode, sharing)
15-12-2016

From my understanding of CDS implementation, the JEP should not affect it. These alternate memories are expected to have the same semantics as DRAM. 3D XPoint for example does support the same semantics and no special handling is required from the application or JVM. That also means atomic operations work the same way as for DRAM memory.
14-12-2016

Does this impact Class Data Sharing at all? Do these alternative memory devices still act as normal memory in all other regards - e.g. supporting atomic operations? Do they have the same memory model as the normal memory on the system?
14-12-2016

We have an implementation for this JEP, the patch for which is uploaded at http://cr.openjdk.java.net/~kkharbas/8153327_webrev.04/ This patch supports the JEP feature in Linux and Windows.
13-12-2016