Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14617#discussion_r109832240
  
    --- Diff: core/src/main/scala/org/apache/spark/storage/StorageUtils.scala 
---
    @@ -176,26 +178,51 @@ class StorageStatus(val blockManagerId: 
BlockManagerId, val maxMem: Long) {
        */
       def numRddBlocksById(rddId: Int): Int = 
_rddBlocks.get(rddId).map(_.size).getOrElse(0)
     
    +  /** Return the max memory can be used by this block manager. */
    +  def maxMem: Long = maxMemory
    +
       /** Return the memory remaining in this block manager. */
       def memRemaining: Long = maxMem - memUsed
     
    +  /** Return the memory used by caching RDDs */
    +  def cacheSize: Long = onHeapCacheSize + offHeapCacheSize
    +
       /** Return the memory used by this block manager. */
    -  def memUsed: Long = _nonRddStorageInfo._1 + cacheSize
    +  def memUsed: Long = onHeapMemUsed + offHeapMemUsed
     
    -  /** Return the memory used by caching RDDs */
    -  def cacheSize: Long = _rddBlocks.keys.toSeq.map(memUsedByRdd).sum
    +  /** Return the on-heap memory remaining in this block manager. */
    +  def onHeapMemRemaining: Option[Long] = maxOnHeapMem.map(_ - 
onHeapMemUsed)
    +
    +  /** Return the off-heap memory remaining in this block manager. */
    +  def offHeapMemRemaining: Option[Long] = maxOffHeapMem.map(_ - 
offHeapMemUsed)
    +
    +  /** Return the on-heap memory used by this block manager. */
    +  def onHeapMemUsed: Long = _nonRddStorageInfo.onHeapUsage + 
onHeapCacheSize
    +
    +  /** Return the off-heap memory used by this block manager. */
    +  def offHeapMemUsed: Long = _nonRddStorageInfo.offHeapUsage + 
offHeapCacheSize
    +
    +  /** Return the memory used by on-heap caching RDDs */
    +  def onHeapCacheSize: Long = _rddStorageInfo.collect {
    +      case (_, storageInfo) if !storageInfo.level.useOffHeap => 
storageInfo.memoryUsage
    +  }.sum
    +
    +  /** Return the memory used by off-heap caching RDDs */
    +  def offHeapCacheSize: Long = _rddStorageInfo.collect {
    --- End diff --
    
    should all methods that return something specific to onheap / offheap 
return an OPtion?  It seems like if it was created from event logs, and the 
SparkListenerBlockManagerAdded even didn't have an onheap / offheap breakdown, 
we can't trust these numbers.
    
    I think it doesn't matter now, in the code you have, since these methods 
won't be called unless you know you have an onheap / offheap breakdown 
available.  But I think it would be a bit more clear if you made that explicit 
with the return types of these functions.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to