You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by jerryshao <gi...@git.apache.org> on 2015/03/17 08:34:31 UTC

[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

GitHub user jerryshao opened a pull request:

    https://github.com/apache/spark/pull/5064

    [SPARK-5523][Core][Streaming] Add a cache for hostname in TaskMetrics to decrease the memory usage and GC overhead

    Hostname in TaskMetrics will be created through deserialization, mostly the number of hostname is only the order of number of cluster node, so adding a cache layer to dedup the object could reduce the memory usage and alleviate GC overhead, especially for long-running and fast job generation applications like Spark Streaming.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jerryshao/apache-spark SPARK-5523

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/5064.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #5064
    
----
commit 7bc3834970a0edafa87813aa83af954118c19f4e
Author: Saisai Shao <sa...@intel.com>
Date:   2015-03-17T06:41:26Z

    Add a pool to cache the hostname

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on the pull request:

    https://github.com/apache/spark/pull/5064#issuecomment-89191467
  
    @JoshRosen Can you take a look at this? I had observed a lot of string objects with hostnames once in the stack, and this might help reduce it. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5064#discussion_r26559706
  
    --- Diff: core/src/main/scala/org/apache/spark/executor/TaskMetrics.scala ---
    @@ -212,10 +213,26 @@ class TaskMetrics extends Serializable {
       private[spark] def updateInputMetrics(): Unit = synchronized {
         inputMetrics.foreach(_.updateBytesRead())
       }
    +
    +  @throws(classOf[IOException])
    +  private def readObject(in: ObjectInputStream): Unit = Utils.tryOrIOException {
    +    in.defaultReadObject()
    +    // Get the hostname from cached data, since hostname is the order of number of nodes in
    +    // cluster, so using cached hostname will decrease the object number and alleviate the GC
    +    // overhead.
    +    _hostname = TaskMetrics.getCachedHostName(_hostname)
    +  }
     }
     
     private[spark] object TaskMetrics {
    +  private val hostNameCache = new ConcurrentHashMap[String, String]()
    --- End diff --
    
    Can this cache get large? meaning, should it be a weak ref map?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/5064#issuecomment-82185694
  
      [Test build #28710 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28710/consoleFull) for   PR 5064 at commit [`7bc3834`](https://github.com/apache/spark/commit/7bc3834970a0edafa87813aa83af954118c19f4e).
     * This patch merges cleanly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/5064#issuecomment-82789948
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28776/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/5064#issuecomment-96770122
  
      [Test build #31051 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/31051/consoleFull) for   PR 5064 at commit [`e4de2b4`](https://github.com/apache/spark/commit/e4de2b4c31ad37ab7bb88fd3df1ea1bab53b02f5).
     * This patch **does not merge cleanly**.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/5064#issuecomment-82210621
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28710/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5064#discussion_r26559827
  
    --- Diff: core/src/main/scala/org/apache/spark/executor/TaskMetrics.scala ---
    @@ -212,10 +213,26 @@ class TaskMetrics extends Serializable {
       private[spark] def updateInputMetrics(): Unit = synchronized {
         inputMetrics.foreach(_.updateBytesRead())
       }
    +
    +  @throws(classOf[IOException])
    +  private def readObject(in: ObjectInputStream): Unit = Utils.tryOrIOException {
    +    in.defaultReadObject()
    +    // Get the hostname from cached data, since hostname is the order of number of nodes in
    +    // cluster, so using cached hostname will decrease the object number and alleviate the GC
    +    // overhead.
    +    _hostname = TaskMetrics.getCachedHostName(_hostname)
    +  }
     }
     
     private[spark] object TaskMetrics {
    +  private val hostNameCache = new ConcurrentHashMap[String, String]()
    +
       def empty: TaskMetrics = new TaskMetrics
    +
    +  def getCachedHostName(host: String): String = {
    +    hostNameCache.putIfAbsent(host, host)
    --- End diff --
    
    Might be slightly faster to avoid the second lookup:
    
    ```
    val canonicalHost = hostNameCache.putIfAbsent(host, host)
    if (canonicalHost == null) host else canonicalHost
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/5064#issuecomment-82210575
  
      [Test build #28710 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28710/consoleFull) for   PR 5064 at commit [`7bc3834`](https://github.com/apache/spark/commit/7bc3834970a0edafa87813aa83af954118c19f4e).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5064#discussion_r26640195
  
    --- Diff: core/src/main/scala/org/apache/spark/executor/TaskMetrics.scala ---
    @@ -212,10 +213,26 @@ class TaskMetrics extends Serializable {
       private[spark] def updateInputMetrics(): Unit = synchronized {
         inputMetrics.foreach(_.updateBytesRead())
       }
    +
    +  @throws(classOf[IOException])
    +  private def readObject(in: ObjectInputStream): Unit = Utils.tryOrIOException {
    +    in.defaultReadObject()
    +    // Get the hostname from cached data, since hostname is the order of number of nodes in
    +    // cluster, so using cached hostname will decrease the object number and alleviate the GC
    +    // overhead.
    +    _hostname = TaskMetrics.getCachedHostName(_hostname)
    +  }
     }
     
     private[spark] object TaskMetrics {
    +  private val hostNameCache = new ConcurrentHashMap[String, String]()
    +
       def empty: TaskMetrics = new TaskMetrics
    +
    +  def getCachedHostName(host: String): String = {
    +    hostNameCache.putIfAbsent(host, host)
    --- End diff --
    
    Thanks, I will change the code.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by jerryshao <gi...@git.apache.org>.
Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5064#discussion_r26638830
  
    --- Diff: core/src/main/scala/org/apache/spark/executor/TaskMetrics.scala ---
    @@ -212,10 +213,26 @@ class TaskMetrics extends Serializable {
       private[spark] def updateInputMetrics(): Unit = synchronized {
         inputMetrics.foreach(_.updateBytesRead())
       }
    +
    +  @throws(classOf[IOException])
    +  private def readObject(in: ObjectInputStream): Unit = Utils.tryOrIOException {
    +    in.defaultReadObject()
    +    // Get the hostname from cached data, since hostname is the order of number of nodes in
    +    // cluster, so using cached hostname will decrease the object number and alleviate the GC
    +    // overhead.
    +    _hostname = TaskMetrics.getCachedHostName(_hostname)
    +  }
     }
     
     private[spark] object TaskMetrics {
    +  private val hostNameCache = new ConcurrentHashMap[String, String]()
    --- End diff --
    
    I think the size of the cache will at most be as large as the cluster size, so weak ref map may not be so necessary from my understanding.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/5064#issuecomment-82789921
  
      [Test build #28776 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28776/consoleFull) for   PR 5064 at commit [`e4de2b4`](https://github.com/apache/spark/commit/e4de2b4c31ad37ab7bb88fd3df1ea1bab53b02f5).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5523][Core][Streaming] Add a cache for ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/5064#issuecomment-82764172
  
      [Test build #28776 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/28776/consoleFull) for   PR 5064 at commit [`e4de2b4`](https://github.com/apache/spark/commit/e4de2b4c31ad37ab7bb88fd3df1ea1bab53b02f5).
     * This patch merges cleanly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org