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
44530c31
Commit
44530c31
authored
14 years ago
by
Matei Zaharia
Browse files
Options
Downloads
Patches
Plain Diff
Made DFS shuffle's "reduce tasks" fetch inputs in a random order so they
don't all hit the same nodes at the same time.
parent
820dac5a
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
src/scala/spark/DfsShuffle.scala
+4
-4
4 additions, 4 deletions
src/scala/spark/DfsShuffle.scala
src/scala/spark/Utils.scala
+17
-1
17 additions, 1 deletion
src/scala/spark/Utils.scala
with
21 additions
and
5 deletions
src/scala/spark/DfsShuffle.scala
+
4
−
4
View file @
44530c31
...
...
@@ -80,8 +80,8 @@ extends Logging
}
val
fs
=
DfsShuffle
.
getFileSystem
()
val
outputStreams
=
(
0
until
numOutputSplits
).
map
(
i
=>
{
val
path
=
new
Path
(
dir
,
"
intermediate-%d
-%d"
.
format
(
myIndex
,
i
))
new
ObjectOutputStream
(
fs
.
create
(
path
,
1.
toShort
))
val
path
=
new
Path
(
dir
,
"
%d-to
-%d"
.
format
(
myIndex
,
i
))
new
ObjectOutputStream
(
fs
.
create
(
path
,
true
))
}).
toArray
for
((
k
,
c
)
<-
combiners
)
{
val
bucket
=
k
.
hashCode
%
numOutputSplits
...
...
@@ -96,8 +96,8 @@ extends Logging
override
def
default
(
key
:
K
)
=
createCombiner
()
}
val
fs
=
DfsShuffle
.
getFileSystem
()
for
(
i
<-
0
until
numInputSplits
)
{
val
path
=
new
Path
(
dir
,
"
intermediate-%d
-%d"
.
format
(
i
,
myIndex
))
for
(
i
<-
Utils
.
shuffle
(
0
until
numInputSplits
)
)
{
val
path
=
new
Path
(
dir
,
"
%d-to
-%d"
.
format
(
i
,
myIndex
))
val
inputStream
=
new
ObjectInputStream
(
fs
.
open
(
path
))
try
{
while
(
true
)
{
...
...
This diff is collapsed.
Click to expand it.
src/scala/spark/Utils.scala
+
17
−
1
View file @
44530c31
...
...
@@ -4,13 +4,14 @@ import java.io._
import
java.util.UUID
import
scala.collection.mutable.ArrayBuffer
import
scala.util.Random
/**
* Various utility methods used by Spark.
*/
object
Utils
{
def
serialize
[
T
](
o
:
T
)
:
Array
[
Byte
]
=
{
val
bos
=
new
ByteArrayOutputStream
val
bos
=
new
ByteArrayOutputStream
()
val
oos
=
new
ObjectOutputStream
(
bos
)
oos
.
writeObject
(
o
)
oos
.
close
...
...
@@ -95,4 +96,19 @@ object Utils {
out
.
close
()
}
}
// Shuffle the elements of a collection into a random order, returning the
// result in a new collection. Unlike scala.util.Random.shuffle, this method
// uses a local random number generator, avoiding inter-thread contention.
def
shuffle
[
T
](
seq
:
Seq
[
T
])
:
Seq
[
T
]
=
{
val
buf
=
ArrayBuffer
(
seq
:
_
*
)
val
rand
=
new
Random
()
for
(
i
<-
(
buf
.
size
-
1
)
to
1
by
-
1
)
{
val
j
=
rand
.
nextInt
(
i
)
val
tmp
=
buf
(
j
)
buf
(
j
)
=
buf
(
i
)
buf
(
i
)
=
tmp
}
buf
}
}
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