sunhaibotb opened a new pull request #7797: [FLINK-11379] Fix OutOfMemoryError 
caused by Files.readAllBytes() when TM loads a large size TDD
URL: https://github.com/apache/flink/pull/7797
 
 
   ## What is the purpose of the change
   
   This pull request makes TM do not throw a "java.lang.OutOfMemoryError: 
Direct Buffer Memory" error In the case of loading a offloaded TDD with large 
size.  The loading uses NIO's Files.readAllBytes() to read serialized TDD, and 
in the call stack of Files.readAllBytes() , it will allocate a direct memory 
buffer which's size is equal to the length of the file. This will cause 
OutOfMemoryError when the file is very large.
   
   
   ## Brief change log
   
     - A new method readAllBytes() which limits the used size of the direct 
buffer is added to the FileUtils class.
       - *The reason for adding this new method is that no an available method 
of Java API or third-party interface has been found. The available method 
should be not only as efficient and scalable (auto-scaling allocated byte 
array) as NIO's Files.available() , but also limits the used size of the direct 
buffer.*
       - *The new method is an implementation that follow nio's 
Files.readAllBytes(),  and the only difference is that it limits the used size 
of the direct buffer.*
     - When TM loads a offloaded TDD, FileUtils.readAllBytes() is called to 
replace nio's Files.readAllBytes().
   
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
     -  Added test that validates that the results of FileUtils.readAllBytes() 
are correct in the following cases:
       - The file size (1K) is smaller than the direct-buffer size (4K).
       -  The file size (4K) is equal to the direct-buffer size (4K).
       -  The file size (5K) is greater than the direct-buffer size (4K).
   
   
   ## 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 GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to