forked from prestodb/presto
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Results run on my development vm BenchmarkReorderJoinsConnectedGraph: BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins ELIMINATE_CROSS_JOINS 2 avgt 30 54.610 ± 4.236 ms/op BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins ELIMINATE_CROSS_JOINS 4 avgt 30 153.794 ± 9.075 ms/op BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins ELIMINATE_CROSS_JOINS 6 avgt 30 326.410 ± 19.912 ms/op BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins ELIMINATE_CROSS_JOINS 8 avgt 30 578.028 ± 33.308 ms/op BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins ELIMINATE_CROSS_JOINS 10 avgt 30 955.494 ± 44.523 ms/op BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins COST_BASED 2 avgt 30 54.844 ± 4.256 ms/op BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins COST_BASED 4 avgt 30 161.164 ± 11.008 ms/op BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins COST_BASED 6 avgt 30 440.007 ± 28.903 ms/op BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins COST_BASED 8 avgt 30 2491.240 ± 72.341 ms/op BenchmarkReorderJoinsConnectedGraph.benchmarkReorderJoins COST_BASED 10 avgt 30 24026.603 ± 886.696 ms/opa BencharkReorderJoinsLinearGraph: BenchmarkReorderJoinsLinearQuery.benchmarkReorderJoins ELIMINATE_CROSS_JOINS avgt 30 944.179 ± 42.406 ms/op BenchmarkReorderJoinsLinearQuery.benchmarkReorderJoins COST_BASED avgt 30 1329.194 ± 71.704 ms/op
- Loading branch information
1 parent
6549cf1
commit c3d1a7a
Showing
2 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
...a/com/facebook/presto/sql/planner/iterative/rule/BenchmarkReorderJoinsConnectedGraph.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Licensed 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.facebook.presto.sql.planner.iterative.rule; | ||
|
||
import com.facebook.presto.Session; | ||
import com.facebook.presto.testing.LocalQueryRunner; | ||
import com.facebook.presto.testing.MaterializedResult; | ||
import com.facebook.presto.testing.QueryRunner; | ||
import com.facebook.presto.tpch.TpchConnectorFactory; | ||
import com.google.common.collect.ImmutableMap; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Param; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.TearDown; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
import org.openjdk.jmh.runner.options.VerboseMode; | ||
|
||
import static com.facebook.presto.testing.TestingSession.testSessionBuilder; | ||
import static com.google.common.base.Preconditions.checkState; | ||
import static java.lang.String.format; | ||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
import static org.openjdk.jmh.annotations.Mode.AverageTime; | ||
import static org.openjdk.jmh.annotations.Scope.Thread; | ||
|
||
@State(Thread) | ||
@OutputTimeUnit(MILLISECONDS) | ||
@BenchmarkMode(AverageTime) | ||
@Fork(3) | ||
@Warmup(iterations = 10) | ||
@Measurement(iterations = 10) | ||
public class BenchmarkReorderJoinsConnectedGraph | ||
{ | ||
@Benchmark | ||
public MaterializedResult benchmarkReorderJoins(BenchmarkInfo benchmarkInfo) | ||
{ | ||
return benchmarkInfo.getQueryRunner().execute(benchmarkInfo.getQuery()); | ||
} | ||
|
||
@State(Thread) | ||
public static class BenchmarkInfo | ||
{ | ||
@Param({"ELIMINATE_CROSS_JOINS", "COST_BASED"}) | ||
private String joinReorderingStrategy; | ||
|
||
@Param({"2", "4", "6", "8", "10"}) | ||
private int numberOfTables; | ||
|
||
private String query; | ||
private LocalQueryRunner queryRunner; | ||
|
||
@Setup | ||
public void setup() | ||
{ | ||
checkState(numberOfTables >= 2, "numberOfTables must be >= 2"); | ||
Session session = testSessionBuilder() | ||
.setSystemProperty("join_reordering_strategy", joinReorderingStrategy) | ||
.setSystemProperty("join_distribution_type", "AUTOMATIC") | ||
.setCatalog("tpch") | ||
.setSchema("tiny") | ||
.build(); | ||
queryRunner = new LocalQueryRunner(session); | ||
queryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of()); | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
stringBuilder.append("EXPLAIN SELECT * FROM NATION n1"); | ||
for (int i = 2; i <= numberOfTables; i++) { | ||
stringBuilder.append(format(" JOIN nation n%s on n%s.nationkey = n%s.nationkey", i, i - 1, i)); | ||
} | ||
query = stringBuilder.toString(); | ||
} | ||
|
||
public String getQuery() | ||
{ | ||
return query; | ||
} | ||
|
||
public QueryRunner getQueryRunner() | ||
{ | ||
return queryRunner; | ||
} | ||
|
||
@TearDown | ||
public void tearDown() | ||
{ | ||
queryRunner.close(); | ||
} | ||
} | ||
|
||
public static void main(String[] args) | ||
throws RunnerException | ||
{ | ||
Options options = new OptionsBuilder() | ||
.verbosity(VerboseMode.NORMAL) | ||
.include(".*" + BenchmarkReorderJoinsConnectedGraph.class.getSimpleName() + ".*") | ||
.build(); | ||
|
||
new Runner(options).run(); | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
...java/com/facebook/presto/sql/planner/iterative/rule/BenchmarkReorderJoinsLinearGraph.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Licensed 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.facebook.presto.sql.planner.iterative.rule; | ||
|
||
import com.facebook.presto.Session; | ||
import com.facebook.presto.testing.LocalQueryRunner; | ||
import com.facebook.presto.testing.MaterializedResult; | ||
import com.facebook.presto.testing.QueryRunner; | ||
import com.facebook.presto.tpch.TpchConnectorFactory; | ||
import com.google.common.collect.ImmutableMap; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Param; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.TearDown; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
import org.openjdk.jmh.runner.options.VerboseMode; | ||
|
||
import static com.facebook.presto.testing.TestingSession.testSessionBuilder; | ||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
import static org.openjdk.jmh.annotations.Mode.AverageTime; | ||
import static org.openjdk.jmh.annotations.Scope.Thread; | ||
|
||
@State(Thread) | ||
@OutputTimeUnit(MILLISECONDS) | ||
@BenchmarkMode(AverageTime) | ||
@Fork(3) | ||
@Warmup(iterations = 10) | ||
@Measurement(iterations = 10) | ||
public class BenchmarkReorderJoinsLinearGraph | ||
{ | ||
@Benchmark | ||
public MaterializedResult benchmarkReorderJoins(BenchmarkInfo benchmarkInfo) | ||
{ | ||
return benchmarkInfo.getQueryRunner().execute( | ||
"EXPLAIN SELECT * FROM " + | ||
"nation n1 JOIN nation n2 ON n1.nationkey = n2.nationkey " + | ||
"JOIN nation n3 on n2.comment = n3.comment " + | ||
"JOIN nation n4 on n3.name = n4.name " + | ||
"JOIN region r1 on n4.regionkey = r1.regionkey " + | ||
"JOIN region r2 on r2.name = r2.name " + | ||
"JOIN region r3 on r3.comment = r2.comment " + | ||
"join region r4 on r4.regionkey = r3.regionkey"); | ||
} | ||
|
||
@State(Thread) | ||
public static class BenchmarkInfo | ||
{ | ||
@Param({"ELIMINATE_CROSS_JOINS", "COST_BASED"}) | ||
private String joinReorderingStrategy; | ||
|
||
private LocalQueryRunner queryRunner; | ||
|
||
@Setup | ||
public void setup() | ||
{ | ||
Session session = testSessionBuilder() | ||
.setSystemProperty("join_reordering_strategy", joinReorderingStrategy) | ||
.setSystemProperty("join_distribution_type", "AUTOMATIC") | ||
.setCatalog("tpch") | ||
.setSchema("tiny") | ||
.build(); | ||
queryRunner = new LocalQueryRunner(session); | ||
queryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of()); | ||
} | ||
|
||
public QueryRunner getQueryRunner() | ||
{ | ||
return queryRunner; | ||
} | ||
|
||
@TearDown | ||
public void tearDown() | ||
{ | ||
queryRunner.close(); | ||
} | ||
} | ||
|
||
public static void main(String[] args) | ||
throws RunnerException | ||
{ | ||
Options options = new OptionsBuilder() | ||
.verbosity(VerboseMode.NORMAL) | ||
.include(".*" + BenchmarkReorderJoinsLinearGraph.class.getSimpleName() + ".*") | ||
.build(); | ||
|
||
new Runner(options).run(); | ||
} | ||
} |