-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-23508][CORE] Fix BlockmanagerId in case blockManagerIdCache cause oom #20667
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
Changes from 1 commit
fc1b6a0
59f34e1
e5e3eff
c741b58
36d66e1
e5b793d
8f3cd47
dc522fc
b28985b
3379899
bf79f4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap | |
|
|
||
| import org.apache.spark.SparkContext | ||
| import org.apache.spark.annotation.DeveloperApi | ||
| import org.apache.spark.util.Utils | ||
| import org.apache.spark.util.{TimeStampedHashMap, Utils} | ||
|
|
||
| /** | ||
| * :: DeveloperApi :: | ||
|
|
@@ -123,7 +123,8 @@ private[spark] object BlockManagerId { | |
| execId: String, | ||
| host: String, | ||
| port: Int, | ||
| topologyInfo: Option[String] = None): BlockManagerId = | ||
| topologyInfo: Option[String] = None, | ||
| clearOldValues: Boolean = false): BlockManagerId = | ||
| getCachedBlockManagerId(new BlockManagerId(execId, host, port, topologyInfo)) | ||
|
|
||
| def apply(in: ObjectInput): BlockManagerId = { | ||
|
|
@@ -132,10 +133,15 @@ private[spark] object BlockManagerId { | |
| getCachedBlockManagerId(obj) | ||
| } | ||
|
|
||
| val blockManagerIdCache = new ConcurrentHashMap[BlockManagerId, BlockManagerId]() | ||
| val blockManagerIdCache = new TimeStampedHashMap[BlockManagerId, BlockManagerId](true) | ||
|
|
||
| def getCachedBlockManagerId(id: BlockManagerId): BlockManagerId = { | ||
| def getCachedBlockManagerId(id: BlockManagerId, clearOldValues: Boolean = false): BlockManagerId = | ||
| { | ||
| blockManagerIdCache.putIfAbsent(id, id) | ||
| blockManagerIdCache.get(id) | ||
| val blockManagerId = blockManagerIdCache.get(id) | ||
| if (clearOldValues) { | ||
| blockManagerIdCache.clearOldValues(System.currentTimeMillis - Utils.timeStringAsMs("10d")) | ||
|
||
| } | ||
| blockManagerId.get | ||
| } | ||
| } | ||
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.
Will this cause serious performance regression?
TimeStampedHashMapwill copy all the old values on update. cc @cloud-fan