chummyhe89 commented on a change in pull request #26984: [SPARK-27641][CORE] Fix MetricsSystem to remove metrics of the specific source by exactly match URL: https://github.com/apache/spark/pull/26984#discussion_r378652761
########## File path: core/src/main/scala/org/apache/spark/metrics/MetricsSystem.scala ########## @@ -169,9 +176,12 @@ private[spark] class MetricsSystem private ( } def removeSource(source: Source): Unit = { - sources -= source - val regName = buildRegistryName(source) - registry.removeMatching((name: String, _: Metric) => name.startsWith(regName)) + val index = sources.indexOf(source) Review comment: `sources` is an ArrayBuffer. if `sources` really contains the checking one,the index can avoid traversing array twice. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org