-
Notifications
You must be signed in to change notification settings - Fork 771
Add repartition workload #608
Changes from 5 commits
3c6007c
14334de
3b6a0fb
bf801cd
708e8e6
296e5ed
b5477ba
fcf13d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/bin/bash | ||
| # 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. | ||
|
|
||
| current_dir=`dirname "$0"` | ||
| current_dir=`cd "$current_dir"; pwd` | ||
| root_dir=${current_dir}/../../../../.. | ||
| workload_config=${root_dir}/conf/workloads/micro/repartition.conf | ||
| . "${root_dir}/bin/functions/load_bench_config.sh" | ||
|
|
||
| enter_bench HadoopPrepareRepartition ${workload_config} ${current_dir} | ||
| show_bannar start | ||
|
|
||
| rmr_hdfs $INPUT_HDFS || true | ||
| START_TIME=`timestamp` | ||
| run_hadoop_job ${HADOOP_EXAMPLES_JAR} teragen \ | ||
| -D mapreduce.job.maps=${NUM_MAPS} \ | ||
| -D mapreduce.job.reduces=${NUM_REDS} \ | ||
| ${DATASIZE} ${INPUT_HDFS} | ||
| END_TIME=`timestamp` | ||
|
|
||
| show_bannar finish | ||
| leave_bench |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/bin/bash | ||
| # 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. | ||
|
|
||
| current_dir=`dirname "$0"` | ||
| current_dir=`cd "$current_dir"; pwd` | ||
| root_dir=${current_dir}/../../../../.. | ||
| workload_config=${root_dir}/conf/workloads/micro/repartition.conf | ||
| . "${root_dir}/bin/functions/load_bench_config.sh" | ||
|
|
||
| enter_bench ScalaRepartition ${workload_config} ${current_dir} | ||
| show_bannar start | ||
|
|
||
| rmr_hdfs $OUTPUT_HDFS || true | ||
|
|
||
| SIZE=`dir_size $INPUT_HDFS` | ||
| START_TIME=`timestamp` | ||
| run_spark_job com.intel.hibench.sparkbench.micro.ScalaRepartition $INPUT_HDFS $OUTPUT_HDFS $CACHE_IN_MEMORY | ||
| END_TIME=`timestamp` | ||
|
|
||
| gen_report ${START_TIME} ${END_TIME} ${SIZE} | ||
| show_bannar finish | ||
| leave_bench | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ micro.sleep | |
| micro.sort | ||
| micro.terasort | ||
| micro.wordcount | ||
| micro.repartition | ||
| micro.dfsioe | ||
|
|
||
| sql.aggregation | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #datagen | ||
| hibench.repartition.tiny.datasize 100000 | ||
| hibench.repartition.small.datasize 10000000 | ||
| hibench.repartition.large.datasize 100000000 | ||
| hibench.repartition.huge.datasize 1000000000 | ||
| hibench.repartition.gigantic.datasize 10000000000 | ||
| hibench.repartition.bigdata.datasize 60000000000 | ||
|
||
|
|
||
| hibench.workload.datasize ${hibench.repartition.${hibench.scale.profile}.datasize} | ||
|
|
||
| # export for shell script | ||
| hibench.workload.input ${hibench.hdfs.data.dir}/Repartition/Input | ||
| hibench.workload.output ${hibench.hdfs.data.dir}/Repartition/Output | ||
|
|
||
| hibench.repartition.cacheinmemory true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * 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.intel.hibench.sparkbench.micro | ||
|
|
||
| import java.util.Random | ||
|
|
||
| import com.intel.hibench.sparkbench.common.IOCommon | ||
| import org.apache.hadoop.examples.terasort.TeraInputFormat | ||
| import org.apache.hadoop.io.Text | ||
| import org.apache.spark._ | ||
| import org.apache.spark.rdd.{CoalescedRDD, RDD, ShuffledRDD} | ||
| import org.apache.spark.storage.StorageLevel | ||
|
|
||
| object ScalaRepartition { | ||
|
|
||
| def main(args: Array[String]) { | ||
| if (args.length != 3) { | ||
| System.err.println( | ||
| s"Usage: $ScalaRepartition <INPUT_HDFS> <OUTPUT_HDFS> <CACHE_IN_MEMORY>" | ||
| ) | ||
| System.exit(1) | ||
| } | ||
| val sparkConf = new SparkConf().setAppName("ScalaRepartition") | ||
| val sc = new SparkContext(sparkConf) | ||
|
|
||
| val data = sc.newAPIHadoopFile[Text, Text, TeraInputFormat](args(0)).map { | ||
| case (k,v) => k.copyBytes ++ v.copyBytes | ||
| } | ||
|
|
||
| if (args(2) == "true") { | ||
| data.persist(StorageLevel.MEMORY_ONLY) | ||
| data.count() | ||
| } else if (args(2) != "false") { | ||
| throw new IllegalArgumentException( | ||
| s"Unrecognizable parameter CACHE_IN_MEMORY: ${args(2)}, should be true or false") | ||
| } | ||
|
|
||
| val mapParallelism = sc.getConf.getInt("spark.default.parallelism", sc.defaultParallelism) | ||
| val reduceParallelism = IOCommon.getProperty("hibench.default.shuffle.parallelism") | ||
| .getOrElse((mapParallelism / 2).toString).toInt | ||
|
|
||
| reparition(data, reduceParallelism).foreach(_ => {}) | ||
|
|
||
| sc.stop() | ||
| } | ||
|
|
||
| // Save a CoalescedRDD than RDD.repartition API | ||
| private def reparition(previous: RDD[Array[Byte]], numReducers: Int): ShuffledRDD[Int, Array[Byte], Array[Byte]] = { | ||
| /** Distributes elements evenly across output partitions, starting from a random partition. */ | ||
| val distributePartition = (index: Int, items: Iterator[Array[Byte]]) => { | ||
| var position = (new Random(index)).nextInt(numReducers) | ||
|
||
| items.map { t => | ||
| // Note that the hash code of the key will just be the key itself. The HashPartitioner | ||
| // will mod it with the number of total partitions. | ||
| position = position + 1 | ||
| (position, t) | ||
| } | ||
| } : Iterator[(Int, Array[Byte])] | ||
|
|
||
| // include a shuffle step so that our upstream tasks are still distributed | ||
| new ShuffledRDD[Int, Array[Byte], Array[Byte]](previous.mapPartitionsWithIndex(distributePartition), | ||
| new HashPartitioner(numReducers)) | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about setting this to hibench.repartition.cacheinmemory to false by default? HiBench measures the execution time of the entire workload and calculates the throughput. Caching in memory seems to be for our own need to measure the shuffle write and shuffle read. So we need to look at the stage level execution time ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!