Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions sql/core/benchmarks/UnsafeArrayDataBenchmark-results.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
================================================================================================
Benchmark UnsafeArrayData
================================================================================================

OpenJDK 64-Bit Server VM 1.8.0_181-b13 on Linux 3.10.0-862.3.2.el7.x86_64
Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
Read UnsafeArrayData: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------
Int 233 / 234 718.6 1.4 1.0X
Double 244 / 244 687.0 1.5 1.0X

OpenJDK 64-Bit Server VM 1.8.0_181-b13 on Linux 3.10.0-862.3.2.el7.x86_64
Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
Write UnsafeArrayData: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------
Int 32 / 33 658.6 1.5 1.0X
Double 73 / 75 287.0 3.5 0.4X

OpenJDK 64-Bit Server VM 1.8.0_181-b13 on Linux 3.10.0-862.3.2.el7.x86_64
Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
Get primitive array from UnsafeArrayData: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------
Int 70 / 72 895.0 1.1 1.0X
Double 141 / 143 446.9 2.2 0.5X

OpenJDK 64-Bit Server VM 1.8.0_181-b13 on Linux 3.10.0-862.3.2.el7.x86_64
Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
Create UnsafeArrayData from primitive array: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------
Int 72 / 73 874.7 1.1 1.0X
Double 145 / 146 433.7 2.3 0.5X


Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ package org.apache.spark.sql.execution.benchmark

import scala.util.Random

import org.apache.spark.benchmark.Benchmark
import org.apache.spark.benchmark.{Benchmark, BenchmarkBase}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.expressions.{UnsafeArrayData, UnsafeRow}
import org.apache.spark.sql.catalyst.expressions.codegen.{BufferHolder, UnsafeArrayWriter}
import org.apache.spark.sql.catalyst.expressions.UnsafeArrayData

/**
* Benchmark [[UnsafeArrayDataBenchmark]] for UnsafeArrayData
* To run this:
* 1. replace ignore(...) with test(...)
* 2. build/sbt "sql/test-only *benchmark.UnsafeArrayDataBenchmark"
*
* Benchmarks in this file are skipped in normal builds.
* To run this benchmark:
* {{{
* 1. without sbt: bin/spark-submit --class <this class> <spark sql test jar>
* 2. build/sbt "sql/test:runMain <this class>"
* 3. generate result: SPARK_GENERATE_BENCHMARK_FILES=1 build/sbt "sql/test:runMain <this class>"
* Results will be written to "benchmarks/UnsafeArrayDataBenchmark-results.txt".
* }}}
*/
class UnsafeArrayDataBenchmark extends BenchmarkWithCodegen {
object UnsafeArrayDataBenchmark extends BenchmarkBase {

def calculateHeaderPortionInBytes(count: Int) : Int = {
/* 4 + 4 * count // Use this expression for SPARK-15962 */
Expand Down Expand Up @@ -77,18 +78,10 @@ class UnsafeArrayDataBenchmark extends BenchmarkWithCodegen {
}
}

val benchmark = new Benchmark("Read UnsafeArrayData", count * iters)
val benchmark = new Benchmark("Read UnsafeArrayData", count * iters, output = output)
benchmark.addCase("Int")(readIntArray)
benchmark.addCase("Double")(readDoubleArray)
benchmark.run
/*
OpenJDK 64-Bit Server VM 1.8.0_91-b14 on Linux 4.4.11-200.fc22.x86_64
Intel Xeon E3-12xx v2 (Ivy Bridge)
Read UnsafeArrayData: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------
Int 252 / 260 666.1 1.5 1.0X
Double 281 / 292 597.7 1.7 0.9X
*/
}

def writeUnsafeArray(iters: Int): Unit = {
Expand Down Expand Up @@ -121,18 +114,10 @@ class UnsafeArrayDataBenchmark extends BenchmarkWithCodegen {
doubleTotalLength = len
}

val benchmark = new Benchmark("Write UnsafeArrayData", count * iters)
val benchmark = new Benchmark("Write UnsafeArrayData", count * iters, output = output)
benchmark.addCase("Int")(writeIntArray)
benchmark.addCase("Double")(writeDoubleArray)
benchmark.run
/*
OpenJDK 64-Bit Server VM 1.8.0_91-b14 on Linux 4.4.11-200.fc22.x86_64
Intel Xeon E3-12xx v2 (Ivy Bridge)
Write UnsafeArrayData: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------
Int 196 / 249 107.0 9.3 1.0X
Double 227 / 367 92.3 10.8 0.9X
*/
}

def getPrimitiveArray(iters: Int): Unit = {
Expand Down Expand Up @@ -167,18 +152,11 @@ class UnsafeArrayDataBenchmark extends BenchmarkWithCodegen {
doubleTotalLength = len
}

val benchmark = new Benchmark("Get primitive array from UnsafeArrayData", count * iters)
val benchmark =
new Benchmark("Get primitive array from UnsafeArrayData", count * iters, output = output)
benchmark.addCase("Int")(readIntArray)
benchmark.addCase("Double")(readDoubleArray)
benchmark.run
/*
OpenJDK 64-Bit Server VM 1.8.0_91-b14 on Linux 4.4.11-200.fc22.x86_64
Intel Xeon E3-12xx v2 (Ivy Bridge)
Get primitive array from UnsafeArrayData: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------
Int 151 / 198 415.8 2.4 1.0X
Double 214 / 394 293.6 3.4 0.7X
*/
}

def putPrimitiveArray(iters: Int): Unit = {
Expand Down Expand Up @@ -209,24 +187,19 @@ class UnsafeArrayDataBenchmark extends BenchmarkWithCodegen {
doubleTotalLen = len
}

val benchmark = new Benchmark("Create UnsafeArrayData from primitive array", count * iters)
val benchmark =
new Benchmark("Create UnsafeArrayData from primitive array", count * iters, output = output)
benchmark.addCase("Int")(createIntArray)
benchmark.addCase("Double")(createDoubleArray)
benchmark.run
/*
OpenJDK 64-Bit Server VM 1.8.0_91-b14 on Linux 4.4.11-200.fc22.x86_64
Intel Xeon E3-12xx v2 (Ivy Bridge)
Create UnsafeArrayData from primitive array: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------
Int 206 / 211 306.0 3.3 1.0X
Double 232 / 406 271.6 3.7 0.9X
*/
}

ignore("Benchmark UnsafeArrayData") {
readUnsafeArray(10)
writeUnsafeArray(10)
getPrimitiveArray(5)
putPrimitiveArray(5)
override def runBenchmarkSuite(): Unit = {
runBenchmark("Benchmark UnsafeArrayData") {
readUnsafeArray(10)
writeUnsafeArray(10)
getPrimitiveArray(5)
putPrimitiveArray(5)
}
}
}