You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/09/23 12:36:34 UTC

[GitHub] [flink] azagrebin opened a new pull request #9747: [FLINK-13985] Use native memory for managed memory

azagrebin opened a new pull request #9747: [FLINK-13985] Use native memory for managed memory
URL: https://github.com/apache/flink/pull/9747
 
 
   ## What is the purpose of the change
   
   This PR introduces allocation of off-heap memory independent of direct buffers and limiting option `-XX:MaxDirectMemorySize`. This implementation uses `sun.misc.Unsafe` for that purpose.
   
   ## Brief change log
   
    - Make tests use `MemorySegmentFactory` to create `MemorySegment` and remove shorthand constructors of `HybridMemorySegment` in favour of `MemorySegmentFactory` methods.
    - Add allocate/release unsafe memory methods to `MemoryUtils`
     - Add a `MemoryUtils#createMemoryGcCleaner` to release memory in phantom reference queue upon GC of the memory owning object (based on `sun.misc.Cleaner` similar to `java.nio.DirectByteBuffer(int cap)`).
     - Add `MemoryUtils#wrapUnsafeMemoryWithByteBuffer` which uses the private constructor `java.nio.DirectByteBuffer(long address, int cap)` to wrap unsafe memory but w/o checking `-XX:MaxDirectMemorySize`.
    - Add an optional custom action to call in `HybridMemorySegment#free` for memory cleanup
    - Change `MemorySegmentFactory#allocateUnpooledOffHeapMemory` to allocate unsafe memory, wrap it with ByteBuffer with `MemoryUtils#wrapUnsafeMemoryWithByteBuffer`, hook a phantom reference queue cleaner upon the buffer GC and create `HybridMemorySegment` with this buffer and its custom cleaner.
   
   ## Verifying this change
   
   Units tests.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services