Skip to content
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

[CORE][GLUTEN-3936] Support collapse project transformer #3937

Merged
merged 2 commits into from
Dec 12, 2023

Conversation

liujiayi771
Copy link
Contributor

What changes were proposed in this pull request?

Fix #3936

How was this patch tested?

Add CollapseProjectExecTransformerSuite

Copy link

github-actions bot commented Dec 5, 2023

Thanks for opening a pull request!

Could you open an issue for this pull request on Github Issues?

https://github.com/oap-project/gluten/issues

Then could you also rename commit message and pull request title in the following format?

[GLUTEN-${ISSUES_ID}][COMPONENT]feat/fix: ${detailed message}

See also:

Copy link

github-actions bot commented Dec 5, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 5, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 6, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 6, 2023

Run Gluten Clickhouse CI

@liujiayi771
Copy link
Contributor Author

@ulysses-you Could you help review?

p2.projectList,
alwaysInline = false) =>
p2.copy(projectList =
CollapseProjectShim.buildCleanedProjectList(p1.projectList, p2.projectList))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be conservative, better to check if the collapsed project can be transformed, and fallback to original plan if fail to validate. Also, do not forget to copy tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not forget to copy tags.

Do you mean that after executing val newProject = p2.copy, I still need to call newProject.copyTagsFrom(p1)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems there is no way to show the fallback reason for a transform node.. so it's ok to skip copying tags.

|LIMIT
| 100;
|""".stripMargin
withSQLConf(GlutenConfig.ENABLE_COLUMNAR_PROJECT_COLLAPSE.key -> "false") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about use a loop to combine two test cases Seq(true, false).foreach { collapsed => }

.internal()
.doc("Combines two columnar project operators into one and perform alias substitution")
.booleanConf
.createWithDefault(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should enable it by default and pass CI to see if there are some bad case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally it was enabled by default, but the unit test for ck failed because some tests in ck directly used the index to retrieve the plan. After my optimization, the number of plans decreased, causing an IndexOutOfBoundsException in the unit test for ck. If it's just for validation, it can be enabled by default and then disabled later.

00:39:58  16:39:58.131 WARN io.glutenproject.metrics.MetricsUtil: Updating native metrics failed due to the wrong size of metrics data: 7
00:39:58  - Check TPCH Q2 metrics updater *** FAILED ***
00:39:58    java.lang.IndexOutOfBoundsException: 10
00:39:58    at scala.collection.mutable.ResizableArray.apply(ResizableArray.scala:46)
00:39:58    at scala.collection.mutable.ResizableArray.apply$(ResizableArray.scala:45)
00:39:58    at scala.collection.mutable.ArrayBuffer.apply(ArrayBuffer.scala:49)
00:39:58    at io.glutenproject.execution.metrics.GlutenClickHouseTPCHMetricsSuite.$anonfun$new$9(GlutenClickHouseTPCHMetricsSuite.scala:210)
00:39:58    at io.glutenproject.execution.metrics.GlutenClickHouseMetricsUTUtils$.executeMetricsUpdater(GlutenClickHouseMetricsUTUtils.scala:117)
00:39:58    at io.glutenproject.execution.metrics.GlutenClickHouseTPCHMetricsSuite.$anonfun$new$7(GlutenClickHouseTPCHMetricsSuite.scala:205)
00:39:58    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
00:39:58    at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
00:39:58    at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
00:39:58    at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just fix it, e.g., change 10 to 9 if we have collapsed two projects into one. I think the code change should be test only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to put it in spark-ut module as it affects both velox and ch backend.

@ulysses-you
Copy link
Contributor

thank you @liujiayi771 , the idea looks good to me

Copy link

github-actions bot commented Dec 6, 2023

Run Gluten Clickhouse CI

1 similar comment
Copy link

github-actions bot commented Dec 6, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 6, 2023

Run Gluten Clickhouse CI

1 similar comment
Copy link

github-actions bot commented Dec 6, 2023

Run Gluten Clickhouse CI

@liujiayi771 liujiayi771 marked this pull request as draft December 7, 2023 04:24
Copy link

github-actions bot commented Dec 7, 2023

Run Gluten Clickhouse CI

1 similar comment
Copy link

github-actions bot commented Dec 7, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 7, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 7, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 7, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 8, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 8, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 8, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 8, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 8, 2023

Run Gluten Clickhouse CI

@liujiayi771 liujiayi771 marked this pull request as ready for review December 9, 2023 14:33
@liujiayi771
Copy link
Contributor Author

@ulysses-you Ready for review. CK's UT needs to be adapted when the optimization is enabled by default, but this optimization will not be enabled by default later on. Unlike Velox, CK does not insert a project to calculate hash value before shuffle, so there are very few cases that meet the criteria for project collapsing. Currently, all UTs can pass. After completing the review, I will turn off the parameter by default and roll back the modifications made to CK's UT.

@ulysses-you
Copy link
Contributor

I think enabled it by default is fine even if the clickhouse backend has less case can be optimized.

@ulysses-you
Copy link
Contributor

/Benchmark Velox

Copy link
Contributor

@ulysses-you ulysses-you left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, cc @zzcclp if you have other comments

@GlutenPerfBot
Copy link
Contributor

===== Performance report for TPCH SF2000 with Velox backend, for reference only ====

query log/native_3937_time.csv log/native_master_12_11_2023_71ec720d4_time.csv difference percentage
q1 33.66 32.10 -1.567 95.35%
q2 25.00 24.79 -0.212 99.15%
q3 37.72 38.42 0.701 101.86%
q4 37.72 39.90 2.187 105.80%
q5 72.10 72.41 0.310 100.43%
q6 7.08 7.02 -0.065 99.08%
q7 85.68 85.38 -0.302 99.65%
q8 87.90 86.65 -1.247 98.58%
q9 127.44 126.76 -0.686 99.46%
q10 42.74 46.79 4.050 109.48%
q11 19.92 20.34 0.426 102.14%
q12 27.20 26.95 -0.250 99.08%
q13 47.31 45.56 -1.748 96.30%
q14 14.50 18.31 3.802 126.21%
q15 28.20 27.78 -0.422 98.50%
q16 15.57 15.83 0.259 101.67%
q17 101.71 101.57 -0.142 99.86%
q18 152.79 151.54 -1.251 99.18%
q19 12.72 12.91 0.188 101.48%
q20 27.97 26.84 -1.133 95.95%
q21 223.90 228.06 4.158 101.86%
q22 14.00 13.81 -0.185 98.68%
total 1242.83 1249.71 6.871 100.55%

@ulysses-you ulysses-you merged commit ccf95f5 into apache:main Dec 12, 2023
17 checks passed
@liujiayi771 liujiayi771 deleted the collapse-project branch December 14, 2023 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CORE] Redundant project transformer can be collapsed
3 participants