Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
c324ac10
Commit
c324ac10
authored
11 years ago
by
Patrick Wendell
Browse files
Options
Downloads
Patches
Plain Diff
Force use of LZF when spilling data
parent
1b299142
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala
+36
-6
36 additions, 6 deletions
.../apache/spark/util/collection/ExternalAppendOnlyMap.scala
docs/configuration.md
+3
-1
3 additions, 1 deletion
docs/configuration.md
with
39 additions
and
7 deletions
core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala
+
36
−
6
View file @
c324ac10
...
@@ -20,14 +20,15 @@ package org.apache.spark.util.collection
...
@@ -20,14 +20,15 @@ package org.apache.spark.util.collection
import
java.io._
import
java.io._
import
java.util.Comparator
import
java.util.Comparator
import
it.unimi.dsi.fastutil.io.FastBufferedInputStream
import
scala.collection.mutable
import
scala.collection.mutable
import
scala.collection.mutable.ArrayBuffer
import
scala.collection.mutable.ArrayBuffer
import
it.unimi.dsi.fastutil.io.FastBufferedInputStream
import
org.apache.spark.
{
Logging
,
SparkEnv
}
import
org.apache.spark.
{
Logging
,
SparkEnv
}
import
org.apache.spark.serializer.
{
KryoDeserializationStream
,
KryoSerializationStream
,
Serializer
}
import
org.apache.spark.io.LZFCompressionCodec
import
org.apache.spark.storage.
{
BlockId
,
BlockManager
,
DiskBlockManager
,
DiskBlockObjectWriter
}
import
org.apache.spark.serializer.
{
KryoDeserializationStream
,
Serializer
}
import
org.apache.spark.storage.
{
BlockId
,
BlockManager
,
DiskBlockObjectWriter
}
/**
/**
* An append-only map that spills sorted content to disk when there is insufficient space for it
* An append-only map that spills sorted content to disk when there is insufficient space for it
...
@@ -153,9 +154,38 @@ private[spark] class ExternalAppendOnlyMap[K, V, C](
...
@@ -153,9 +154,38 @@ private[spark] class ExternalAppendOnlyMap[K, V, C](
.
format
(
mapSize
/
(
1024
*
1024
),
spillCount
,
if
(
spillCount
>
1
)
"s"
else
""
))
.
format
(
mapSize
/
(
1024
*
1024
),
spillCount
,
if
(
spillCount
>
1
)
"s"
else
""
))
val
(
blockId
,
file
)
=
diskBlockManager
.
createTempBlock
()
val
(
blockId
,
file
)
=
diskBlockManager
.
createTempBlock
()
val
compressStream
:
OutputStream
=>
OutputStream
=
blockManager
.
wrapForCompression
(
blockId
,
_
)
/* IMPORTANT NOTE: To avoid having to keep large object graphs in memory, this approach
* closes and re-opens serialization and compression streams within each file. This makes some
* assumptions about the way that serialization and compression streams work, specifically:
*
* 1) The serializer input streams do not pre-fetch data from the underlying stream.
*
* 2) Several compression streams can be opened, written to, and flushed on the write path
* while only one compression input stream is created on the read path
*
* In practice (1) is only true for Java, so we add a special fix below to make it work for
* Kryo. (2) is only true for LZF and not Snappy, so we coerce this to use LZF.
*
* To avoid making these assumptions we should create an intermediate stream that batches
* objects and sends an EOF to the higher layer streams to make sure they never prefetch data.
* This is a bit tricky because, within each segment, you'd need to track the total number
* of bytes written and then re-wind and write it at the beginning of the segment. This will
* most likely require using the file channel API.
*/
val
codec
=
new
LZFCompressionCodec
(
sparkConf
)
def
wrapForCompression
(
outputStream
:
OutputStream
)
=
{
blockManager
.
shouldCompress
(
blockId
)
match
{
case
true
=>
codec
.
compressedOutputStream
(
outputStream
)
case
false
=>
outputStream
}
}
def
getNewWriter
=
new
DiskBlockObjectWriter
(
blockId
,
file
,
serializer
,
fileBufferSize
,
def
getNewWriter
=
new
DiskBlockObjectWriter
(
blockId
,
file
,
serializer
,
fileBufferSize
,
c
ompress
Stream
,
syncWrites
)
wrapForC
ompress
ion
,
syncWrites
)
var
writer
=
getNewWriter
var
writer
=
getNewWriter
var
objectsWritten
=
0
var
objectsWritten
=
0
...
...
This diff is collapsed.
Click to expand it.
docs/configuration.md
+
3
−
1
View file @
c324ac10
...
@@ -158,7 +158,9 @@ Apart from these, the following properties are also available, and may be useful
...
@@ -158,7 +158,9 @@ Apart from these, the following properties are also available, and may be useful
<td>
spark.shuffle.spill.compress
</td>
<td>
spark.shuffle.spill.compress
</td>
<td>
true
</td>
<td>
true
</td>
<td>
<td>
Whether to compress data spilled during shuffles.
Whether to compress data spilled during shuffles. If enabled, spill compression
always uses the
`org.apache.spark.io.LZFCompressionCodec`
codec,
regardless of the value of
`spark.io.compression.codec`
.
</td>
</td>
</tr>
</tr>
<tr>
<tr>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment