You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celeborn.apache.org by GitBox <gi...@apache.org> on 2022/11/15 13:39:01 UTC

[GitHub] [incubator-celeborn] waitinfuture commented on a diff in pull request #970: [CELEBORN-3] Add metrics for top disk usage apps for version 0.1.x.

waitinfuture commented on code in PR #970:
URL: https://github.com/apache/incubator-celeborn/pull/970#discussion_r1022647699


##########
common/src/main/proto/TransportMessages.proto:
##########
@@ -106,7 +106,7 @@ message PbHeartbeatFromWorker {
   int32 fetchPort = 4;
   int32 replicatePort = 5;
   int32 numSlots = 6;
-  repeated string shuffleKeys = 7;
+  map<string,int64> shuffleDiskUsage = 7;

Review Comment:
   space after comma



##########
common/src/main/scala/com/aliyun/emr/rss/common/RssConf.scala:
##########
@@ -835,6 +835,18 @@ object RssConf extends Logging {
     conf.getTimeAsMs("rss.rpc.cache.expire", "15s")
   }
 
+  def metricsAppTopDiskUsageCount(conf: RssConf): Int = {
+    conf.getInt("rss.metrics.app.topDiskUsage.count", 50)
+  }
+
+  def metricsAppTopDiskUsageWindowSize(conf: RssConf): Int = {
+    conf.getInt("rss.metrics.app.topDiskUsage.windowSize", 24)
+  }
+
+  def metricsAppTopDiskUsageInterval(conf: RssConf): Long = {
+    conf.getTimeAsSeconds("rss.metrids.app.topDiskUsage.interval", "1h")

Review Comment:
   metrics



##########
server-master/src/main/java/com/aliyun/emr/rss/service/deploy/master/clustermeta/ha/MetaHandler.java:
##########
@@ -156,8 +157,10 @@ public ResourceResponse handleWriteRequest(
           LOG.debug("Handle worker heartbeat for {} {} {} {} {} {}",
                    host, rpcPort, pushPort, fetchPort, replicatePort, numSlots);
           time = request.getWorkerHeartBeatRequest().getTime();
+          Map<String,Long> diskUsageMap = request

Review Comment:
   ditto



##########
server-master/src/main/java/com/aliyun/emr/rss/service/deploy/master/metrics/AppDiskUsageMetric.scala:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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 com.aliyun.emr.rss.service.deploy.master.metrics
+
+import java.util
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.atomic.AtomicReference
+import com.aliyun.emr.rss.common.RssConf
+import com.aliyun.emr.rss.common.internal.Logging
+import com.aliyun.emr.rss.common.meta.WorkerInfo
+import com.aliyun.emr.rss.common.util.{ThreadUtils, Utils}
+
+import java.time.LocalDateTime
+import scala.collection.JavaConverters.{iterableAsScalaIterableConverter, mapAsScalaMapConverter}
+
+case class AppDiskUsage(var appId: String, var usage: Long) {
+  override def toString: String = s"Application ${appId} used ${Utils.bytesToString(usage)} "
+}
+
+class AppDiskUsageSnapShot(val topItemCount: Int) extends Logging {
+  val topNItems = new Array[AppDiskUsage](topItemCount)

Review Comment:
   I think we'd better use PriorityQueue instead of Array.



##########
server-master/src/main/java/com/aliyun/emr/rss/service/deploy/master/metrics/AppDiskUsageMetric.scala:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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 com.aliyun.emr.rss.service.deploy.master.metrics
+
+import java.util
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.atomic.AtomicReference
+import com.aliyun.emr.rss.common.RssConf
+import com.aliyun.emr.rss.common.internal.Logging
+import com.aliyun.emr.rss.common.meta.WorkerInfo
+import com.aliyun.emr.rss.common.util.{ThreadUtils, Utils}
+
+import java.time.LocalDateTime
+import scala.collection.JavaConverters.{iterableAsScalaIterableConverter, mapAsScalaMapConverter}
+
+case class AppDiskUsage(var appId: String, var usage: Long) {
+  override def toString: String = s"Application ${appId} used ${Utils.bytesToString(usage)} "
+}
+
+class AppDiskUsageSnapShot(val topItemCount: Int) extends Logging {
+  val topNItems = new Array[AppDiskUsage](topItemCount)
+  val startSnapShotTime = LocalDateTime.now()
+  var endSnapShotTime: LocalDateTime = _
+
+  def commit(): Unit = {
+    endSnapShotTime = LocalDateTime.now()
+  }
+
+  def updateAppDiskUsage(appId: String, usage: Long): Unit = {
+    val dropIndex = topNItems.indexWhere(usage => usage != null && usage.appId == appId)
+    if (dropIndex != -1) {
+      drop(dropIndex)
+    }
+    val insertIndex = findInsertPosition(usage)
+    if (insertIndex != -1) {
+      shift(insertIndex)
+      topNItems(insertIndex) = AppDiskUsage(appId, usage)
+    }
+  }
+
+  def shift(index: Int): Unit = {
+    for (i <- topItemCount - 1 until index by -1) {
+      topNItems(i) = topNItems(i - 1)
+    }
+  }
+
+  def drop(index: Int): Unit = {
+    for (i <- index until topItemCount - 1) {
+      topNItems(i) = topNItems(i + 1)
+    }

Review Comment:
   should set null to the last index



##########
common/src/main/scala/com/aliyun/emr/rss/common/RssConf.scala:
##########
@@ -835,6 +835,18 @@ object RssConf extends Logging {
     conf.getTimeAsMs("rss.rpc.cache.expire", "15s")
   }
 
+  def metricsAppTopDiskUsageCount(conf: RssConf): Int = {
+    conf.getInt("rss.metrics.app.topDiskUsage.count", 50)
+  }
+
+  def metricsAppTopDiskUsageWindowSize(conf: RssConf): Int = {
+    conf.getInt("rss.metrics.app.topDiskUsage.windowSize", 24)
+  }
+
+  def metricsAppTopDiskUsageInterval(conf: RssConf): Long = {
+    conf.getTimeAsSeconds("rss.metrids.app.topDiskUsage.interval", "1h")

Review Comment:
   1h is too long, better default to 10min



##########
server-master/src/main/java/com/aliyun/emr/rss/service/deploy/master/clustermeta/AbstractMetaManager.java:
##########
@@ -287,4 +287,8 @@ public void updateBlacklistByReportWorkerFailure(List<WorkerInfo> failedWorkers)
       this.blacklist.addAll(failedWorkers);
     }
   }
+
+  public Map<WorkerInfo,Map<String,Long>> getAppDiskUsageDetailsSnapShot(){
+    return new HashMap<>(this.appDiskUsageDetails);

Review Comment:
   better to remove this.



##########
server-worker/src/main/scala/com/aliyun/emr/rss/service/deploy/worker/Worker.scala:
##########
@@ -186,19 +186,24 @@ private[deploy] class Worker(
   }
 
   def heartBeatToMaster(): Unit = {
-    val shuffleKeys = new jHashSet[String]
-    shuffleKeys.addAll(partitionLocationInfo.shuffleKeySet)
-    shuffleKeys.addAll(localStorageManager.shuffleKeySet())
+    val shuffleResourceConsumption = new jHashMap[String, java.lang.Long]
+    partitionLocationInfo.shuffleKeySet.asScala.foreach { shuffleKey =>
+      shuffleResourceConsumption.put(shuffleKey, 0)

Review Comment:
   Is it necessary to initial all shuffleKeys to 0?



-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org