forked from taegeonum/incubator-nemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEMO-350] Implement Off-heap SerializedMemoryStore & [NEMO-384] Impl…
…ement DirectByteBufferInputStream for Off-heap SerializedMemoryStore (apache#222) JIRA: [NEMO-350: Implement Off-heap SerializedMemoryStore](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-#350) [NEMO-384: Implement DirectByteBufferInputStream for Off-heap SerializedMemoryStore](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-#384) **Major changes:** - When a block is emitted by an executor, we write it directly to off-heap memory using `DirectByteBufferOutputStream` and `DirectByteBufferOutputStream`. **Minor changes to note:** - `getData()` and `getBuffer` should be distinguished when acquiring data in `SerializedPartition` **Other comments:** - This implementation does not ensure performance gain since the overhead of `allocateDirect` (malloc) surpasses the garbage collection overhead. For this reason, memory management is being implemented.
- Loading branch information
Showing
14 changed files
with
252 additions
and
298 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
common/src/main/java/org/apache/nemo/common/ByteBufferInputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.nemo.common; | ||
|
||
import java.io.EOFException; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.ByteBuffer; | ||
import java.util.List; | ||
|
||
/** | ||
* This class is a customized input stream implementation which reads data from | ||
* list of {@link ByteBuffer}. If the {@link ByteBuffer} is direct, it may reside outside | ||
* the normal garbage-collected heap memory. | ||
*/ | ||
public class ByteBufferInputStream extends InputStream { | ||
private List<ByteBuffer> bufList; | ||
private int current = 0; | ||
private static final int BITMASK = 0xff; | ||
|
||
/** | ||
* Default Constructor. | ||
* | ||
* @param bufList is the target data to read. | ||
*/ | ||
public ByteBufferInputStream(final List<ByteBuffer> bufList) { | ||
this.bufList = bufList; | ||
} | ||
|
||
/** | ||
* Reads data from the list of {@code ByteBuffer}s. | ||
* | ||
* @return integer. | ||
* @throws IOException | ||
*/ | ||
@Override | ||
public int read() throws IOException { | ||
// Since java's byte is signed type, we have to mask it to make byte | ||
// become unsigned type to properly retrieve `int` from sequence of bytes. | ||
return getBuffer().get() & BITMASK; | ||
} | ||
|
||
/** | ||
* Return next non-empty @code{ByteBuffer}. | ||
* | ||
* @return @code{ByteBuffer} to write the data | ||
* @throws IOException when fail to retrieve buffer. | ||
*/ | ||
public ByteBuffer getBuffer() throws IOException { | ||
while (current < bufList.size()) { | ||
ByteBuffer buffer = bufList.get(current); | ||
if (buffer.hasRemaining()) { | ||
return buffer; | ||
} | ||
current += 1; | ||
} | ||
throw new EOFException(); | ||
} | ||
} |
55 changes: 0 additions & 55 deletions
55
common/src/main/java/org/apache/nemo/common/DirectByteArrayOutputStream.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.