-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce calcite 2902 #300
base: kycalcite-spark3-1.16.0.x-4.x
Are you sure you want to change the base?
Introduce calcite 2902 #300
Conversation
Calcite Upgrade ReportBenchmarkpackage org.apache.kylin.query.engine;
import org.apache.calcite.rel.RelRoot;
import org.apache.calcite.sql.parser.SqlParseException;
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.common.util.NLocalFileMetadataTestCase;
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.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.results.format.ResultFormatType;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = 1)
@Measurement(iterations = 30)
@Threads(8)
@Fork(value = 1, jvmArgs = {"-Xms4G", "-Xmx4G"})
@State(Scope.Benchmark)
public class QueryOptimizerBenchmark {
private QueryExec qe;
private String sql;
private RelRoot node;
@Setup
public void setUp() throws Exception {
NLocalFileMetadataTestCase case1 = new NLocalFileMetadataTestCase();
case1.createTestMetadata();
KylinConfig.getInstanceFromEnv().setProperty("kylin.query.dataframe-cache-enabled", "false");
}
@Benchmark
public void optimizeRel() throws SqlParseException {
String sql = "SELECT \n" +
"P_LINEORDER.LO_SHIPMODE as P_LINEORDER_LO_SHIPMODE,\n" +
"P_LINEORDER.LO_LINENUMBER as P_LINEORDER_LO_LINENUMBER,\n" +
"P_LINEORDER.LO_ORDTOTALPRICE as P_LINEORDER_LO_ORDTOTALPRICE,\n" +
"P_LINEORDER.LO_SUPPLYCOST as P_LINEORDER_LO_SUPPLYCOST,\n" +
"P_LINEORDER.LO_SUPPKEY as P_LINEORDER_LO_SUPPKEY,\n" +
"P_LINEORDER.LO_QUANTITY as P_LINEORDER_LO_QUANTITY,\n" +
"P_LINEORDER.LO_PARTKEY as P_LINEORDER_LO_PARTKEY,\n" +
"P_LINEORDER.LO_ORDERKEY as P_LINEORDER_LO_ORDERKEY,\n" +
"P_LINEORDER.LO_CUSTKEY as P_LINEORDER_LO_CUSTKEY,\n" +
"P_LINEORDER.LO_SHIPPRIOTITY as P_LINEORDER_LO_SHIPPRIOTITY,\n" +
"P_LINEORDER.LO_DISCOUNT as P_LINEORDER_LO_DISCOUNT,\n" +
"P_LINEORDER.LO_ORDERPRIOTITY as P_LINEORDER_LO_ORDERPRIOTITY,\n" +
"P_LINEORDER.LO_ORDERDATE as P_LINEORDER_LO_ORDERDATE,\n" +
"P_LINEORDER.LO_REVENUE as P_LINEORDER_LO_REVENUE,\n" +
"P_LINEORDER.V_REVENUE as P_LINEORDER_V_REVENUE,\n" +
"P_LINEORDER.LO_COMMITDATE as P_LINEORDER_LO_COMMITDATE,\n" +
"P_LINEORDER.LO_EXTENDEDPRICE as P_LINEORDER_LO_EXTENDEDPRICE,\n" +
"P_LINEORDER.LO_TAX as P_LINEORDER_LO_TAX,\n" +
"DATES.D_WEEKNUMINYEAR as DATES_D_WEEKNUMINYEAR,\n" +
"DATES.D_LASTDAYINWEEKFL as DATES_D_LASTDAYINWEEKFL,\n" +
"DATES.D_LASTDAYINMONTHFL as DATES_D_LASTDAYINMONTHFL,\n" +
"DATES.D_DAYOFWEEK as DATES_D_DAYOFWEEK,\n" +
"DATES.D_MONTHNUMINYEAR as DATES_D_MONTHNUMINYEAR,\n" +
"DATES.D_YEARMONTHNUM as DATES_D_YEARMONTHNUM,\n" +
"DATES.D_YEARMONTH as DATES_D_YEARMONTH,\n" +
"DATES.D_DAYNUMINMONTH as DATES_D_DAYNUMINMONTH,\n" +
"DATES.D_SELLINGSEASON as DATES_D_SELLINGSEASON,\n" +
"DATES.D_WEEKDAYFL as DATES_D_WEEKDAYFL,\n" +
"DATES.D_YEAR as DATES_D_YEAR,\n" +
"DATES.D_HOLIDAYFL as DATES_D_HOLIDAYFL,\n" +
"DATES.D_DAYNUMINWEEK as DATES_D_DAYNUMINWEEK,\n" +
"DATES.D_DAYNUMINYEAR as DATES_D_DAYNUMINYEAR,\n" +
"DATES.D_DATE as DATES_D_DATE,\n" +
"DATES.D_MONTH as DATES_D_MONTH,\n" +
"DATES.D_DATEKEY as DATES_D_DATEKEY,\n" +
"CUSTOMER.C_ADDRESS as CUSTOMER_C_ADDRESS,\n" +
"CUSTOMER.C_NATION as CUSTOMER_C_NATION,\n" +
"CUSTOMER.C_CITY as CUSTOMER_C_CITY,\n" +
"CUSTOMER.C_PHONE as CUSTOMER_C_PHONE,\n" +
"CUSTOMER.C_REGION as CUSTOMER_C_REGION,\n" +
"CUSTOMER.C_NAME as CUSTOMER_C_NAME,\n" +
"CUSTOMER.C_MKTSEGMENT as CUSTOMER_C_MKTSEGMENT,\n" +
"CUSTOMER.C_CUSTKEY as CUSTOMER_C_CUSTKEY,\n" +
"PART.P_PARTKEY as PART_P_PARTKEY,\n" +
"PART.P_CONTAINER as PART_P_CONTAINER,\n" +
"PART.P_SIZE as PART_P_SIZE,\n" +
"PART.P_NAME as PART_P_NAME,\n" +
"PART.P_CATEGORY as PART_P_CATEGORY,\n" +
"PART.P_TYPE as PART_P_TYPE,\n" +
"PART.P_MFGR as PART_P_MFGR,\n" +
"PART.P_BRAND as PART_P_BRAND,\n" +
"PART.P_COLOR as PART_P_COLOR,\n" +
"SUPPLIER.S_ADDRESS as SUPPLIER_S_ADDRESS,\n" +
"SUPPLIER.S_NAME as SUPPLIER_S_NAME,\n" +
"SUPPLIER.S_NATION as SUPPLIER_S_NATION,\n" +
"SUPPLIER.S_SUPPKEY as SUPPLIER_S_SUPPKEY,\n" +
"SUPPLIER.S_REGION as SUPPLIER_S_REGION,\n" +
"SUPPLIER.S_PHONE as SUPPLIER_S_PHONE,\n" +
"SUPPLIER.S_CITY as SUPPLIER_S_CITY\n" +
"FROM \n" +
"SSB.P_LINEORDER as P_LINEORDER \n" +
"LEFT JOIN SSB.DATES as DATES\n" +
"ON P_LINEORDER.LO_ORDERDATE=DATES.D_DATEKEY\n" +
"LEFT JOIN SSB.CUSTOMER as CUSTOMER\n" +
"ON P_LINEORDER.LO_CUSTKEY=CUSTOMER.C_CUSTKEY\n" +
"LEFT JOIN SSB.PART as PART\n" +
"ON P_LINEORDER.LO_PARTKEY=PART.P_PARTKEY\n" +
"LEFT JOIN SSB.SUPPLIER as SUPPLIER\n" +
"ON P_LINEORDER.LO_SUPPKEY=SUPPLIER.S_SUPPKEY";
QueryExec qe = new QueryExec("demo", KylinConfig.getInstanceFromEnv());
RelRoot node = qe.sqlConverter.convertSqlToRelNode(sql);
for(int i = 0; i <= 3000; i++){
qe.optimize(node);
}
}
public static void main(String[] args) throws Exception {
Options opts = new OptionsBuilder()
.include(QueryOptimizerBenchmark.class.getSimpleName())
.resultFormat(ResultFormatType.JSON)
.build();
new Runner(opts).run();
}
} Before(1.116.0-kylin-4.x-r021)
After(1.116.0-kylin-4.x-r024)
Conclusion>>> before=4116.604
>>> after=2805.872
>>> improve=(before - after)/before
>>> improve
0.3184012841652975 Improve 32.84% |
@@ -20,12 +20,12 @@ limitations under the License. | |||
<parent> | |||
<groupId>org.apache.calcite</groupId> | |||
<artifactId>calcite</artifactId> | |||
<version>1.116.0-kylin-4.x-r023</version> | |||
<version>1.116.0-kylin-4.x-r024</version> |
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.
Can we use a property to indicate the version and manage the related dependency to the dependencyManagement?
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.
Good idea, but now the main pom.xml will update the version with every change. So the related dependencies are clear to be managed.
fce55c3
to
c9173b3
Compare
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@calcite.apache.org list. Thank you for your contributions. |
No description provided.