Skip to content

Commit b76b95f

Browse files
committed
Review feedback
1 parent 4e1514e commit b76b95f

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

core/src/main/scala/org/apache/spark/storage/BlockFetcherIterator.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ object BlockFetcherIterator {
149149
// Make remote requests at most maxBytesInFlight / 5 in length; the reason to keep them
150150
// smaller than maxBytesInFlight is to allow multiple, parallel fetches from up to 5
151151
// nodes, rather than blocking on reading output from one node.
152-
val maxRequestSize = math.max(maxBytesInFlight / 5, 1L)
153-
logInfo("maxBytesInFlight: " + maxBytesInFlight + ", maxRequestSize: " + maxRequestSize)
152+
val targetRequestSize = math.max(maxBytesInFlight / 5, 1L)
153+
logInfo("maxBytesInFlight: " + maxBytesInFlight + ", targetRequestSize: " + targetRequestSize)
154154

155155
// Split local and remote blocks. Remote blocks are further split into FetchRequests of size
156156
// at most maxBytesInFlight in order to limit the amount of data in flight.
@@ -177,7 +177,7 @@ object BlockFetcherIterator {
177177
} else if (size < 0) {
178178
throw new BlockException(blockId, "Negative block size " + size)
179179
}
180-
if (curRequestSize >= maxRequestSize) {
180+
if (curRequestSize >= targetRequestSize) {
181181
// Add this FetchRequest
182182
remoteRequests += new FetchRequest(address, curBlocks)
183183
curRequestSize = 0

core/src/main/scala/org/apache/spark/storage/DiskStore.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import org.apache.spark.util.Utils
3333
private class DiskStore(blockManager: BlockManager, diskManager: DiskBlockManager)
3434
extends BlockStore(blockManager) with Logging {
3535

36+
val minMemoryMapBytes = blockManager.conf.getLong("spark.storage.memoryMapThreshold", 2 * 4096L)
37+
3638
override def getSize(blockId: BlockId): Long = {
3739
diskManager.getBlockLocation(blockId).length
3840
}
@@ -87,7 +89,7 @@ private class DiskStore(blockManager: BlockManager, diskManager: DiskBlockManage
8789

8890
val buffer =
8991
// For small files, directly read rather than memory map
90-
if (segment.length < 2 * 4096) {
92+
if (segment.length < minMemoryMapBytes) {
9193
val buf = ByteBuffer.allocate(segment.length.toInt)
9294
try {
9395
channel.read(buf, segment.offset)

docs/configuration.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ Apart from these, the following properties are also available, and may be useful
122122
<code>spark.storage.memoryFraction</code>.
123123
</td>
124124
</tr>
125+
<tr>
126+
<td>spark.storage.memoryMapThreshold</td>
127+
<td>2 * 4096</td>
128+
<td>
129+
Size of a block, in bytes, above which Spark memory maps when reading a block from disk.
130+
This prevents Spark from memory mapping very small blocks. In general, memory
131+
mapping has high overhead for blocks close to or below the page size of the operating system.
132+
</td>
133+
</tr>
125134
<tr>
126135
<td>spark.mesos.coarse</td>
127136
<td>false</td>

0 commit comments

Comments
 (0)