-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates and Fixes to Make spark-memory work on opensource spark #4
Open
AndrewKL
wants to merge
6
commits into
squito:master
Choose a base branch
from
AndrewKL:bonfire-updates
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3fdbf55
commit by Octane
ad5de48
Merge remote-tracking branch 'github/master' into mainline
AndrewKL be37d37
[BONFIRE] Added support for EMR and fixed a name space issue that pre…
AndrewKL 68529ee
[BONFIRE] Updated the README.md to include an introduction and an exa…
AndrewKL 0ebbf8d
[BONFIRE] refactored the MemoryMonitorExecutorExtension into its own …
AndrewKL 5652206
[BONFIRE] Added test to verify that the correct ExecutorPlugin classe…
AndrewKL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,37 @@ | ||
# -*-perl-*- | ||
|
||
package.Spark-memory = { | ||
interfaces = (1.0); | ||
|
||
deploy = { | ||
generic = true; | ||
}; | ||
|
||
build-environment = { | ||
chroot = basic; | ||
network-access = blocked; | ||
}; | ||
|
||
# Use NoOpBuild. See https://w.amazon.com/index.php/BrazilBuildSystem/NoOpBuild | ||
build-system = no-op; | ||
build-tools = { | ||
1.0 = { | ||
NoOpBuild = 1.0; | ||
}; | ||
}; | ||
|
||
# Use runtime-dependencies for when you want to bring in additional | ||
# packages when deploying. | ||
# Use dependencies instead if you intend for these dependencies to | ||
# be exported to other packages that build against you. | ||
dependencies = { | ||
1.0 = { | ||
}; | ||
}; | ||
|
||
runtime-dependencies = { | ||
1.0 = { | ||
}; | ||
}; | ||
|
||
}; |
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
62 changes: 62 additions & 0 deletions
62
core/src/main/scala/com/cloudera/spark/MemoryMonitorExecutorExtension.scala
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,62 @@ | ||
package com.cloudera.spark | ||
|
||
import java.util.concurrent.atomic.{AtomicInteger, AtomicReference} | ||
import java.util.concurrent.{ScheduledFuture, ScheduledThreadPoolExecutor, ThreadFactory, TimeUnit} | ||
|
||
import org.apache.spark.TaskContext | ||
import org.apache.spark.executor.ExecutorPlugin | ||
|
||
class MemoryMonitorExecutorExtension extends ExecutorPlugin with org.apache.spark.ExecutorPlugin { | ||
// the "extension class" api just lets you invoke a constructor. We really just want to | ||
// call this static method, so that's good enough. | ||
MemoryMonitor.installIfSysProps() | ||
val args = MemoryMonitorArgs.sysPropsArgs | ||
|
||
val monitoredTaskCount = new AtomicInteger(0) | ||
|
||
val scheduler = if (args.stagesToPoll != null && args.stagesToPoll.nonEmpty) { | ||
// TODO share polling executors? | ||
new ScheduledThreadPoolExecutor(1, new ThreadFactory { | ||
override def newThread(r: Runnable): Thread = { | ||
val t = new Thread(r, "thread-dump poll thread") | ||
t.setDaemon(true) | ||
t | ||
} | ||
}) | ||
} else { | ||
null | ||
} | ||
val pollingTask = new AtomicReference[ScheduledFuture[_]]() | ||
|
||
override def taskStart(taskContext: TaskContext): Unit = { | ||
if (args.stagesToPoll.contains(taskContext.stageId())) { | ||
if (monitoredTaskCount.getAndIncrement() == 0) { | ||
// TODO schedule thread polling | ||
val task = scheduler.scheduleWithFixedDelay(new Runnable { | ||
override def run(): Unit = { | ||
val d = MemoryMonitor.dateFormat.format(System.currentTimeMillis()) | ||
println(s"Polled thread dump @ $d") | ||
MemoryMonitor.showThreadDump(MemoryMonitor.getThreadInfo) | ||
} | ||
}, 0, args.threadDumpFreqMillis, TimeUnit.MILLISECONDS) | ||
pollingTask.set(task) | ||
} | ||
} | ||
} | ||
|
||
override def onTaskFailure(context: TaskContext, error: Throwable): Unit = { | ||
removeActiveTask(context) | ||
} | ||
|
||
override def onTaskCompletion(context: TaskContext): Unit = { | ||
removeActiveTask(context) | ||
} | ||
|
||
private def removeActiveTask(context: TaskContext): Unit = { | ||
if (args.stagesToPoll.contains(context.stageId())) { | ||
if (monitoredTaskCount.decrementAndGet() == 0) { | ||
pollingTask.get().cancel(false) | ||
} | ||
} | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
core/src/main/scala/org/apache/spark/memory/SparkMemoryManagerHandle.scala
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
10 changes: 10 additions & 0 deletions
10
core/src/test/scala/com/cloudera/spark/MemoryMonitorExecutorExtension.scala
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,10 @@ | ||
package com.cloudera.spark | ||
|
||
import org.scalatest.FunSuite | ||
|
||
class MemoryMonitorExecutorExtensionSuite extends FunSuite { | ||
test("MemoryMonitorExecutorExtension should extend the correct class of ExecutorPlugin") { | ||
assert(classOf[MemoryMonitorExecutorExtension].getInterfaces.contains(classOf[org.apache.spark.executor.ExecutorPlugin])) | ||
assert(classOf[MemoryMonitorExecutorExtension].getInterfaces.contains(classOf[org.apache.spark.ExecutorPlugin])) | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove this file from the pr please?