filmov
tv
[2min] Understanding Java 14 NVM feature

Показать описание
Summary
Java 14 adds new JDK-specific file mapping modes so that the FileChannel API can be used to create MappedByteBuffer instances that refer to non-volatile memory.
FileChannel use
Let's first understand what is FileChannel.
FileChannel is a nexus for I/O operations.
FileChannel is used for advanced applications needing file locking or memory-mapped I/O.
A channel is for reading, writing, mapping, and manipulating a file.
A file channel is a SeekableByteChannel that is connected to a file. It has a current position within its file which can be both queried and modified. The file itself contains a variable-length sequence of bytes that can be read and written and whose current size can be queried. The size of the file increases when bytes are written beyond its current size; the size of the file decreases when it is truncated. The file may also have some associated metadata such as access permissions, content type, and last-modification time; this class does not define methods for metadata access.
MappedByteBuffer
Let's understand what is MappedByteBuffer.
MappedByteBuffer is a ByteBuffer(used to transfer bytes) with operations that are specific to memory-mapped file regions.
By "memory-mapped file regions", I mean the ability to truncate the file in parts and handle(read/write) it independently.
MappedByteBuffer is a direct byte buffer(outside of JVM and heap) by representing a memory-mapped region of a file.
Key advantage of MappedByteBuffer is the resiliency at program crash when reading/writing (say OS will take care of writing content to File.)
Non Volatile Memory
Let's understand the advantages of Non-volatile memory:
With non-volatile memory, data or information remains keep within the memory albeit power is completed.
Non-volatile memory offers also many attractions:
Reduced startup time
Reduced latency of durable updates
Higher memory density and lower cost/bit than DRAM
Conclusion
With JDK 14, FileChannel API can be used to create MappedByteBuffer instances that refer to non-volatile memory
Links
FileChannel JavaDoc
MappedByteBuffer JavaDoc
NVM Definition
NVM Lab
JEP 352 Specification
#technology #java #java14 #nvm #programming #jep352 #javalanguageprogramming #programming #mappedbytebuffer #filechannel
Java 14 adds new JDK-specific file mapping modes so that the FileChannel API can be used to create MappedByteBuffer instances that refer to non-volatile memory.
FileChannel use
Let's first understand what is FileChannel.
FileChannel is a nexus for I/O operations.
FileChannel is used for advanced applications needing file locking or memory-mapped I/O.
A channel is for reading, writing, mapping, and manipulating a file.
A file channel is a SeekableByteChannel that is connected to a file. It has a current position within its file which can be both queried and modified. The file itself contains a variable-length sequence of bytes that can be read and written and whose current size can be queried. The size of the file increases when bytes are written beyond its current size; the size of the file decreases when it is truncated. The file may also have some associated metadata such as access permissions, content type, and last-modification time; this class does not define methods for metadata access.
MappedByteBuffer
Let's understand what is MappedByteBuffer.
MappedByteBuffer is a ByteBuffer(used to transfer bytes) with operations that are specific to memory-mapped file regions.
By "memory-mapped file regions", I mean the ability to truncate the file in parts and handle(read/write) it independently.
MappedByteBuffer is a direct byte buffer(outside of JVM and heap) by representing a memory-mapped region of a file.
Key advantage of MappedByteBuffer is the resiliency at program crash when reading/writing (say OS will take care of writing content to File.)
Non Volatile Memory
Let's understand the advantages of Non-volatile memory:
With non-volatile memory, data or information remains keep within the memory albeit power is completed.
Non-volatile memory offers also many attractions:
Reduced startup time
Reduced latency of durable updates
Higher memory density and lower cost/bit than DRAM
Conclusion
With JDK 14, FileChannel API can be used to create MappedByteBuffer instances that refer to non-volatile memory
Links
FileChannel JavaDoc
MappedByteBuffer JavaDoc
NVM Definition
NVM Lab
JEP 352 Specification
#technology #java #java14 #nvm #programming #jep352 #javalanguageprogramming #programming #mappedbytebuffer #filechannel