Skip to content

[CORE][VL] Add naitve plan string and plan with stats#3787

Merged
zhouyuan merged 3 commits into
apache:mainfrom
ulysses-you:native-plan
Nov 21, 2023
Merged

[CORE][VL] Add naitve plan string and plan with stats#3787
zhouyuan merged 3 commits into
apache:mainfrom
ulysses-you:native-plan

Conversation

@ulysses-you
Copy link
Copy Markdown
Contributor

@ulysses-you ulysses-you commented Nov 21, 2023

What changes were proposed in this pull request?

This pr adds two things:

  1. Support inject native plan string to Spark explain, e.g.,

--conf spark.gluten.sql.injectNativePlanStringToExplain=true

(9) WholeStageCodegenTransformer (2)
Input [6]: [c1#0L, c2#1L, c3#2L, c1#3L, c2#4L, c3#5L]
Arguments: false
Native Plan:
-- Project[expressions: (n3_6:BIGINT, "n0_0"), (n3_7:BIGINT, "n0_1"), (n3_8:BIGINT, "n0_2"), (n3_9:BIGINT, "n1_0"), (n3_10:BIGINT, "n1_1"), (n3_11:BIGINT, "n1_2")] -> n3_6:BIGINT, n3_7:BIGINT, n3_8:BIGINT, n3_9:BIGINT, n3_10:BIGINT, n3_11:BIGINT
  -- HashJoin[INNER n1_1=n0_1] -> n1_0:BIGINT, n1_1:BIGINT, n1_2:BIGINT, n0_0:BIGINT, n0_1:BIGINT, n0_2:BIGINT
    -- TableScan[table: hive_table, range filters: [(c2, Filter(IsNotNull, deterministic, null not allowed))]] -> n1_0:BIGINT, n1_1:BIGINT, n1_2:BIGINT
    -- ValueStream[] -> n0_0:BIGINT, n0_1:BIGINT, n0_2:BIGINT
  1. Support print plan with stats to executor system output stream. Note, it's task level so it will print plan with stats for each task, e.g,

--conf spark.gluten.sql.debug=true

I20231121 10:35:50.516695 90119467 WholeStageResultIterator.cc:220] Native Plan with stats for: [Stage: 0 TID: 7]
-- Project[expressions: (n1_1:BIGINT, add("n0_0",1))] -> n1_1:BIGINT
   Output: 10 rows (96B, 1 batches), Cpu time: 44.50us, Blocked wall time: 0ns, Peak memory: 192B, Memory allocations: 1, Threads: 1
      queuedWallNanos              sum: 2.00us, count: 1, min: 2.00us, max: 2.00us
      runningAddInputWallNanos     sum: 1.21us, count: 1, min: 1.21us, max: 1.21us
      runningFinishWallNanos       sum: 0ns, count: 1, min: 0ns, max: 0ns
      runningGetOutputWallNanos    sum: 63.87us, count: 1, min: 63.87us, max: 63.87us
  -- TableScan[table: hive_table] -> n0_0:BIGINT
     Input: 10 rows (160B, 1 batches), Output: 10 rows (160B, 1 batches), Cpu time: 482.29us, Blocked wall time: 0ns, Peak memory: 960B, Memory allocations: 10, Threads: 1, Splits: 1
        dataSourceWallNanos              sum: 1.73ms, count: 1, min: 1.73ms, max: 1.73ms
        flattenStringDictionaryValues    sum: 0, count: 1, min: 0, max: 0
        ioWaitNanos                      sum: 650.00us, count: 1, min: 650.00us, max: 650.00us
        localReadBytes                   sum: 0B, count: 1, min: 0B, max: 0B
        numLocalRead                     sum: 0, count: 1, min: 0, max: 0
        numPrefetch                      sum: 0, count: 1, min: 0, max: 0
        numRamRead                       sum: 0, count: 1, min: 0, max: 0
        numStorageRead                   sum: 2, count: 1, min: 2, max: 2
        overreadBytes                    sum: 0B, count: 1, min: 0B, max: 0B
        prefetchBytes                    sum: 0B, count: 1, min: 0B, max: 0B
        queryThreadIoLatency             sum: 2, count: 1, min: 2, max: 2
        ramReadBytes                     sum: 0B, count: 1, min: 0B, max: 0B
        runningAddInputWallNanos         sum: 0ns, count: 1, min: 0ns, max: 0ns
        runningFinishWallNanos           sum: 42ns, count: 1, min: 42ns, max: 42ns
        runningGetOutputWallNanos        sum: 2.49ms, count: 1, min: 2.49ms, max: 2.49ms
        skippedSplitBytes                sum: 0B, count: 1, min: 0B, max: 0B
        skippedSplits                    sum: 0, count: 1, min: 0, max: 0
        skippedStrides                   sum: 0, count: 1, min: 0, max: 0
        storageReadBytes                 sum: 1.16KB, count: 1, min: 1.16KB, max: 1.16KB
        totalScanTime                    sum: 0ns, count: 1, min: 0ns, max: 0ns

How was this patch tested?

manually test, see the added docs

@github-actions
Copy link
Copy Markdown

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:

@github-actions
Copy link
Copy Markdown

Run Gluten Clickhouse CI

@Yohahaha
Copy link
Copy Markdown
Contributor

Yohahaha commented Nov 21, 2023

#1 is great, but I think #2 could be added in #3748 with debug config, thus we can avoid add more and more config, how do you think about that?

@ulysses-you
Copy link
Copy Markdown
Contributor Author

@Yohahaha I'm fine to reuse an existed config spark.gluten.sql.debug

@github-actions
Copy link
Copy Markdown

Run Gluten Clickhouse CI

@github-actions
Copy link
Copy Markdown

Run Gluten Clickhouse CI

@ulysses-you
Copy link
Copy Markdown
Contributor Author

cc @Yohahaha @philo-he @zhouyuan @JkSelf thank you

Copy link
Copy Markdown
Member

@zhouyuan zhouyuan left a comment

Choose a reason for hiding this comment

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

👍

@Yohahaha
Copy link
Copy Markdown
Contributor

LGTM!

@zhouyuan zhouyuan merged commit b40a5f0 into apache:main Nov 21, 2023
@zhouyuan
Copy link
Copy Markdown
Member

thank you @ulysses-you and @Yohahaha !

@GlutenPerfBot
Copy link
Copy Markdown
Contributor

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

query log/native_3787_time.csv log/native_master_11_20_2023_60fc2a02e_time.csv difference percentage
q1 34.15 34.37 0.222 100.65%
q2 24.60 24.70 0.106 100.43%
q3 37.04 35.40 -1.642 95.57%
q4 36.78 36.40 -0.380 98.97%
q5 71.18 68.86 -2.319 96.74%
q6 7.44 7.01 -0.424 94.30%
q7 85.24 85.39 0.147 100.17%
q8 85.85 87.44 1.589 101.85%
q9 119.42 124.93 5.508 104.61%
q10 45.59 46.83 1.242 102.72%
q11 19.67 19.99 0.325 101.65%
q12 24.93 24.57 -0.358 98.57%
q13 45.78 44.85 -0.927 97.98%
q14 15.56 18.77 3.215 120.67%
q15 27.56 27.13 -0.425 98.46%
q16 15.39 15.41 0.024 100.15%
q17 100.11 102.21 2.095 102.09%
q18 147.84 149.83 1.988 101.34%
q19 15.32 13.48 -1.847 87.94%
q20 27.95 28.10 0.150 100.54%
q21 221.87 220.09 -1.771 99.20%
q22 12.93 12.89 -0.042 99.68%
total 1222.18 1228.65 6.475 100.53%

@ulysses-you ulysses-you deleted the native-plan branch November 21, 2023 13:45
@GlutenPerfBot
Copy link
Copy Markdown
Contributor

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

query log/native_master_11_21_2023_time.csv log/native_master_11_20_2023_60fc2a02e_time.csv difference percentage
q1 33.71 34.37 0.657 101.95%
q2 24.92 24.70 -0.220 99.12%
q3 37.63 35.40 -2.231 94.07%
q4 35.99 36.40 0.405 101.13%
q5 70.48 68.86 -1.618 97.70%
q6 7.11 7.01 -0.094 98.68%
q7 84.08 85.39 1.312 101.56%
q8 87.02 87.44 0.416 100.48%
q9 124.24 124.93 0.691 100.56%
q10 46.06 46.83 0.766 101.66%
q11 19.24 19.99 0.750 103.90%
q12 25.38 24.57 -0.812 96.80%
q13 45.84 44.85 -0.989 97.84%
q14 18.33 18.77 0.444 102.42%
q15 28.80 27.13 -1.668 94.21%
q16 15.37 15.41 0.046 100.30%
q17 100.95 102.21 1.260 101.25%
q18 146.37 149.83 3.462 102.37%
q19 12.89 13.48 0.589 104.57%
q20 28.27 28.10 -0.168 99.41%
q21 222.09 220.09 -1.999 99.10%
q22 12.99 12.89 -0.104 99.20%
total 1227.75 1228.65 0.898 100.07%

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.

4 participants