-
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 10 commits
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 |
|---|---|---|
|
|
@@ -18,7 +18,8 @@ | |
| package org.apache.spark.storage | ||
|
|
||
| import java.io.{Externalizable, IOException, ObjectInput, ObjectOutput} | ||
| import java.util.concurrent.ConcurrentHashMap | ||
|
|
||
| import com.google.common.cache.{CacheBuilder, CacheLoader} | ||
|
|
||
| import org.apache.spark.SparkContext | ||
| import org.apache.spark.annotation.DeveloperApi | ||
|
|
@@ -132,10 +133,17 @@ private[spark] object BlockManagerId { | |
| getCachedBlockManagerId(obj) | ||
| } | ||
|
|
||
| val blockManagerIdCache = new ConcurrentHashMap[BlockManagerId, BlockManagerId]() | ||
| /** | ||
| * Here we set max cache size as 10000.Since the size of a BlockManagerId object | ||
| * is about 48B,so the max memory this cache cost will be about 1MB which is feasible. | ||
| */ | ||
| val blockManagerIdCache = CacheBuilder.newBuilder() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it thread-safe?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is thread-safe which i refer from: |
||
| .maximumSize(10000) | ||
| .build(new CacheLoader[BlockManagerId, BlockManagerId]() { | ||
| override def load(id: BlockManagerId) = id | ||
| }) | ||
|
|
||
| def getCachedBlockManagerId(id: BlockManagerId): BlockManagerId = { | ||
| blockManagerIdCache.putIfAbsent(id, id) | ||
| blockManagerIdCache.get(id) | ||
| } | ||
| } | ||
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.
nit: