[GitHub] [spark] viirya commented on a change in pull request #26085: [SPARK-29434][Core] Improve the MapStatuses Serialization Performance

2019-10-18 Thread GitBox
viirya commented on a change in pull request #26085: [SPARK-29434][Core] 
Improve the MapStatuses Serialization Performance
URL: https://github.com/apache/spark/pull/26085#discussion_r336697274
 
 

 ##
 File path: core/src/main/scala/org/apache/spark/MapOutputTracker.scala
 ##
 @@ -822,18 +830,42 @@ private[spark] object MapOutputTracker extends Logging {
 } {
   objOut.close()
 }
-val arr = out.toByteArray
+
+val arr: Array[Byte] = {
+  val zos = new ZstdOutputStream(compressedOut)
+  Utils.tryWithSafeFinally {
+compressedOut.write(DIRECT)
+// `out.writeTo(zos)` will write the uncompressed data from `out` to 
`zos`
+//  without copying to avoid unnecessary allocation and copy of byte[].
+out.writeTo(zos)
+  } {
+zos.close()
+  }
+  compressedOut.toByteArray
+}
 if (arr.length >= minBroadcastSize) {
   // Use broadcast instead.
   // Important arr(0) is the tag == DIRECT, ignore that while 
deserializing !
   val bcast = broadcastManager.newBroadcast(arr, isLocal)
   // toByteArray creates copy, so we can reuse out
 
 Review comment:
   this is super nit: toByteArray is called on  compressedOut, instead of out. 
this comment is a bit misleading.


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



[GitHub] [spark] viirya commented on a change in pull request #26085: [SPARK-29434] [Core] Improve the MapStatuses Serialization Performance

2019-10-16 Thread GitBox
viirya commented on a change in pull request #26085: [SPARK-29434] [Core] 
Improve the MapStatuses Serialization Performance
URL: https://github.com/apache/spark/pull/26085#discussion_r335748643
 
 

 ##
 File path: 
core/src/test/scala/org/apache/spark/MapStatusesSerializationBenchmark.scala
 ##
 @@ -0,0 +1,103 @@
+/*
+ * 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
+
+import org.apache.spark.benchmark.Benchmark
+import org.apache.spark.benchmark.BenchmarkBase
+import org.apache.spark.scheduler.CompressedMapStatus
+import org.apache.spark.storage.BlockManagerId
+
+/**
+ * Benchmark for MapStatuses serialization performance.
+ * {{{
+ *   To run this benchmark:
+ *   1. without sbt: bin/spark-submit --class 
+ *--jars ,, 
+ *   2. build/sbt "avro/test:runMain "
+ *   3. generate result: SPARK_GENERATE_BENCHMARK_FILES=1 build/sbt 
"core/test:runMain "
+ *  Results will be written to "benchmarks/AvroReadBenchmark-results.txt".
 
 Review comment:
   avro?


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



[GitHub] [spark] viirya commented on a change in pull request #26085: [SPARK-29434] [Core] Improve the MapStatuses Serialization Performance

2019-10-16 Thread GitBox
viirya commented on a change in pull request #26085: [SPARK-29434] [Core] 
Improve the MapStatuses Serialization Performance
URL: https://github.com/apache/spark/pull/26085#discussion_r335747691
 
 

 ##
 File path: core/src/main/scala/org/apache/spark/MapOutputTracker.scala
 ##
 @@ -822,18 +830,42 @@ private[spark] object MapOutputTracker extends Logging {
 } {
   objOut.close()
 }
-val arr = out.toByteArray
+
+val arr: Array[Byte] = {
+  val zos = new ZstdOutputStream(compressedOut)
+  Utils.tryWithSafeFinally {
+compressedOut.write(DIRECT)
+// `out.writeTo(zos)` will write the uncompressed data from `out` to 
`zos`
+//  without copying to avoid unnecessary allocation and copy of byte[].
+out.writeTo(zos)
+  } {
+zos.close()
+  }
+  compressedOut.toByteArray
+}
 if (arr.length >= minBroadcastSize) {
   // Use broadcast instead.
   // Important arr(0) is the tag == DIRECT, ignore that while 
deserializing !
   val bcast = broadcastManager.newBroadcast(arr, isLocal)
   // toByteArray creates copy, so we can reuse out
 
 Review comment:
   This comment is out-of-dated now. Can be removed or updated, I think.


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



[GitHub] [spark] viirya commented on a change in pull request #26085: [SPARK-29434] [Core] Improve the MapStatuses Serialization Performance

2019-10-11 Thread GitBox
viirya commented on a change in pull request #26085: [SPARK-29434] [Core] 
Improve the MapStatuses Serialization Performance
URL: https://github.com/apache/spark/pull/26085#discussion_r334170378
 
 

 ##
 File path: core/src/main/scala/org/apache/spark/MapOutputTracker.scala
 ##
 @@ -822,18 +827,43 @@ private[spark] object MapOutputTracker extends Logging {
 } {
   objOut.close()
 }
-val arr = out.toByteArray
+
+val arr: Array[Byte] = {
+  val compressedOut = new ByteArrayOutputStream(4096)
+  val zos = new ZstdOutputStream(compressedOut)
 
 Review comment:
   Is the default compress level good for us?


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



[GitHub] [spark] viirya commented on a change in pull request #26085: [SPARK-29434] [Core] Improve the MapStatuses Serialization Performance

2019-10-10 Thread GitBox
viirya commented on a change in pull request #26085: [SPARK-29434] [Core] 
Improve the MapStatuses Serialization Performance
URL: https://github.com/apache/spark/pull/26085#discussion_r333778200
 
 

 ##
 File path: core/src/main/scala/org/apache/spark/MapOutputTracker.scala
 ##
 @@ -20,8 +20,9 @@ package org.apache.spark
 import java.io._
 import java.util.concurrent.{ConcurrentHashMap, LinkedBlockingQueue, 
ThreadPoolExecutor, TimeUnit}
 import java.util.concurrent.locks.ReentrantReadWriteLock
-import java.util.zip.{GZIPInputStream, GZIPOutputStream}
 
+import com.github.luben.zstd.ZstdInputStream
+import com.github.luben.zstd.ZstdOutputStream
 
 Review comment:
   I recall we put third party imports under java and scala.


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



[GitHub] [spark] viirya commented on a change in pull request #26085: [SPARK-29434] [Core] Improve the MapStatuses Serialization Performance

2019-10-10 Thread GitBox
viirya commented on a change in pull request #26085: [SPARK-29434] [Core] 
Improve the MapStatuses Serialization Performance
URL: https://github.com/apache/spark/pull/26085#discussion_r333821336
 
 

 ##
 File path: core/src/test/scala/org/apache/spark/MapOutputTrackerSuite.scala
 ##
 @@ -333,4 +333,63 @@ class MapOutputTrackerSuite extends SparkFunSuite {
 rpcEnv.shutdown()
   }
 
+  ignore("Benchmarking `MapOutputTracker.serializeMapStatuses`") {
+val newConf = new SparkConf
+
+// needs TorrentBroadcast so need a SparkContext
+withSpark(new SparkContext("local", "MapOutputTrackerSuite", newConf)) { 
sc =>
+  val tracker = 
sc.env.mapOutputTracker.asInstanceOf[MapOutputTrackerMaster]
+  val rpcEnv = sc.env.rpcEnv
+  val masterEndpoint = new MapOutputTrackerMasterEndpoint(rpcEnv, tracker, 
newConf)
+  rpcEnv.stop(tracker.trackerEndpoint)
+  rpcEnv.setupEndpoint(MapOutputTracker.ENDPOINT_NAME, masterEndpoint)
 
 Review comment:
   Do we need to set up those if we just benchmark serializeMapStatuses?


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