attilapiros commented on a change in pull request #24499: [SPARK-25888][Core] 
Serve local disk persisted blocks by the external service after releasing 
executor by dynamic allocation
URL: https://github.com/apache/spark/pull/24499#discussion_r281588954
 
 

 ##########
 File path: 
core/src/test/scala/org/apache/spark/storage/BlockManagerInfoSuite.scala
 ##########
 @@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.storage
+
+import java.util.{HashMap => JHashMap}
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.SparkFunSuite
+
+class BlockManagerInfoSuite extends SparkFunSuite {
+
+  def testWithShuffleServiceOnOff(testName: String)
+      (f: (Boolean, BlockManagerInfo) => Unit): Unit = {
+    Seq(true, false).foreach { svcEnabled =>
+      val bmInfo = new BlockManagerInfo(
+        BlockManagerId("executor0", "host", 1234, None),
+        timeMs = 300,
+        maxOnHeapMem = 10000,
+        maxOffHeapMem = 20000,
+        slaveEndpoint = null,
+        if (svcEnabled) Some(new JHashMap[BlockId, BlockStatus]) else None)
+      test(s"$testName externalShuffleServiceEnabled=$svcEnabled") {
+        f(svcEnabled, bmInfo)
+      }
+    }
+  }
+
+  testWithShuffleServiceOnOff("broadcast block") { (_, bmInfo) =>
+    val broadcastId: BlockId = BroadcastBlockId(0, "field1")
+    bmInfo.updateBlockInfo(
+      broadcastId, StorageLevel.MEMORY_AND_DISK, memSize = 200, diskSize = 100)
+    assert(bmInfo.blocks.asScala ===
+      Map(broadcastId -> BlockStatus(StorageLevel.MEMORY_AND_DISK, 0, 100)))
+    assert(bmInfo.exclusiveCachedBlocks.isEmpty)
+    assert(bmInfo.remainingMem === 29800)
+  }
+
+  testWithShuffleServiceOnOff("RDD block with MEMORY_ONLY") { (svcEnabled, 
bmInfo) =>
+    val rddId: BlockId = RDDBlockId(0, 0)
+    bmInfo.updateBlockInfo(rddId, StorageLevel.MEMORY_ONLY, memSize = 200, 
diskSize = 0)
+    assert(bmInfo.blocks.asScala ===
+      Map(rddId -> BlockStatus(StorageLevel.MEMORY_ONLY, 200, 0)))
+    assert(bmInfo.exclusiveCachedBlocks === Set(rddId))
+    assert(bmInfo.remainingMem === 29800)
+    if (svcEnabled) {
+      assert(bmInfo.externalShuffleServiceBlockStatus.get.isEmpty)
+    }
+  }
+
+  testWithShuffleServiceOnOff("RDD block with MEMORY_AND_DISK") { (svcEnabled, 
bmInfo) =>
+    val rddId: BlockId = RDDBlockId(0, 0)
+    bmInfo.updateBlockInfo(
+      rddId, StorageLevel.MEMORY_AND_DISK, memSize = 200, diskSize = 400)
 
 Review comment:
   Yes this is the effective storage level.
   
   Actually as I see an effective storage level can never ever be 
`StorageLevel.MEMORY_AND_DISK`. 
   In my walk through we reached the conclusion that always the 
`BlockManager#getCurrentBlockStatus` is used for computing the effective 
storage level (or it could also come from `BlockStatus#empty` which means 
`StorageLevel$#NONE` so that case is not relevant). So in 
`getCurrentBlockStatus` the level is calculated from the requested level which 
there referenced as `level`, and the related code:
   
   
https://github.com/apache/spark/blob/3e7797aa02a48e653b3c167a62cba6512a1d3bcb/core/src/main/scala/org/apache/spark/storage/BlockManager.scala#L691-L701
   
   You are right a block either can be found in the memory store or in the disk 
store (I have double checked it by focusing to  how 
`BlockManager#doPutIterator` uses the result of  
`MemoryStore#putIteratorAsValues`). 
   
   So in the `getCurrentBlockStatus` either  `inMem` or `onDisk` is true:
   
   ```scala
      val inMem = level.useMemory && memoryStore.contains(blockId) 
      val onDisk = level.useDisk && diskStore.contains(blockId) 
   ```
   
   Based on the analysis above I would delete this test with with 
`MEMORY_AND_DISK`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to