You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Jay Narale (Jira)" <ji...@apache.org> on 2022/01/26 07:21:00 UTC
[jira] [Comment Edited] (CALCITE-4994) SqlToRelConverter creates FieldMap for every Identifier Instead of Memoizing it
[ https://issues.apache.org/jira/browse/CALCITE-4994?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17482295#comment-17482295 ]
Jay Narale edited comment on CALCITE-4994 at 1/26/22, 7:20 AM:
---------------------------------------------------------------
[~julianhyde] Benchmarks for Memoization
1. Here is the benchmark done from SqlString to Rel
Before Change
{noformat}
Benchmark (columnLength) (length) Mode Cnt Score Error Units
SqlToRelBenchmark.parse 10 10000 avgt 10 856.562 ± 38.717 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 10 10000 avgt 10 483.733 ± 13.833 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 10 10000 avgt 10 701324085.600 ± 39465.820 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 10 10000 avgt 10 476.272 ± 203.095 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 10 10000 avgt 10 691588300.800 ± 304688028.003 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 10 10000 avgt 10 2.684 ± 3.198 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 10 10000 avgt 10 3905840.000 ± 4698628.651 B/op
SqlToRelBenchmark.parse:·gc.count 10 10000 avgt 10 11.000 counts
SqlToRelBenchmark.parse:·gc.time 10 10000 avgt 10 115.000 ms
SqlToRelBenchmark.parse 100 10000 avgt 10 1722.243 ± 52.744 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 100 10000 avgt 10 429.921 ± 9.949 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 100 10000 avgt 10 1015519904.000 ± 1464061.426 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 100 10000 avgt 10 427.008 ± 215.019 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 100 10000 avgt 10 1004745523.200 ± 489941534.693 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 100 10000 avgt 10 2.748 ± 2.065 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 100 10000 avgt 10 6497039.200 ± 4893463.920 B/op
SqlToRelBenchmark.parse:·gc.count 100 10000 avgt 10 16.000 counts
SqlToRelBenchmark.parse:·gc.time 100 10000 avgt 10 169.000 ms
SqlToRelBenchmark.parse 1000 10000 avgt 10 11692.547 ± 851.444 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 1000 10000 avgt 10 348.097 ± 23.548 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 1000 10000 avgt 10 4452909090.400 ± 15612.795 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 1000 10000 avgt 10 351.376 ± 41.195 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 1000 10000 avgt 10 4495664742.400 ± 441960646.820 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Old_Gen 1000 10000 avgt 10 1.736 ± 6.089 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Old_Gen.norm 1000 10000 avgt 10 22115972.000 ± 76405252.332 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 1000 10000 avgt 10 2.004 ± 1.353 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 1000 10000 avgt 10 25541660.800 ± 18005770.534 B/op
SqlToRelBenchmark.parse:·gc.count 1000 10000 avgt 10 75.000 counts
SqlToRelBenchmark.parse:·gc.time 1000 10000 avgt 10 798.000 ms{noformat}
After Change
{noformat}
Benchmark (columnLength) (length) Mode Cnt Score Error Units
SqlToRelBenchmark.parse 10 10000 avgt 10 1097.489 ± 601.332 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 10 10000 avgt 10 410.155 ± 124.156 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 10 10000 avgt 10 668138544.000 ± 20234.919 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 10 10000 avgt 10 400.142 ± 123.542 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 10 10000 avgt 10 651270553.600 ± 6713379.946 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 10 10000 avgt 10 0.760 ± 0.763 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 10 10000 avgt 10 1221336.800 ± 1021068.328 B/op
SqlToRelBenchmark.parse:·gc.count 10 10000 avgt 10 10.000 counts
SqlToRelBenchmark.parse:·gc.time 10 10000 avgt 10 76.000 ms
SqlToRelBenchmark.parse 100 10000 avgt 10 1574.153 ± 37.087 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 100 10000 avgt 10 302.032 ± 5.232 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 100 10000 avgt 10 666304293.600 ± 15652.357 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 100 10000 avgt 10 292.489 ± 2.859 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 100 10000 avgt 10 645293670.400 ± 7166058.122 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 100 10000 avgt 10 0.679 ± 0.471 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 100 10000 avgt 10 1501587.200 ± 1065005.841 B/op
SqlToRelBenchmark.parse:·gc.count 100 10000 avgt 10 10.000 counts
SqlToRelBenchmark.parse:·gc.time 100 10000 avgt 10 59.000 ms
SqlToRelBenchmark.parse 1000 10000 avgt 10 8805.355 ± 81.191 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 1000 10000 avgt 10 68.407 ± 0.613 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 1000 10000 avgt 10 669883507.200 ± 15678.613 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 1000 10000 avgt 10 69.629 ± 11.177 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 1000 10000 avgt 10 681888491.200 ± 109763637.726 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 1000 10000 avgt 10 1.946 ± 0.899 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 1000 10000 avgt 10 19059080.800 ± 8796351.410 B/op
SqlToRelBenchmark.parse:·gc.count 1000 10000 avgt 10 60.000 counts
SqlToRelBenchmark.parse:·gc.time 1000 10000 avgt 10 485.000 {noformat}
2. Here is the benchmark done from SqlNode to RelNode
Before
{noformat}
Benchmark (columnLength) (length) Mode Cnt Score Error Units
SqlNodeToRelBenchmark.convertToRel 10 10000 avgt 10 303.435 ± 45.051 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 10 10000 avgt 10 477.892 ± 29.078 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 10 10000 avgt 10 698375281.600 ± 18118.684 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 10 10000 avgt 10 477.193 ± 206.791 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 10 10000 avgt 10 698613760.000 ± 311974407.144 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 10 10000 avgt 10 2.122 ± 5.715 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 10 10000 avgt 10 3206512.800 ± 8744399.798 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 10 10000 avgt 10 11.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 10 10000 avgt 10 187.000 ms
SqlNodeToRelBenchmark.convertToRel 100 10000 avgt 10 649.239 ± 40.462 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 100 10000 avgt 10 429.163 ± 11.149 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 100 10000 avgt 10 1013260700.000 ± 15640.769 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 100 10000 avgt 10 426.631 ± 214.136 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 100 10000 avgt 10 1003696947.200 ± 488659899.338 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 100 10000 avgt 10 1.852 ± 2.396 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 100 10000 avgt 10 4362263.200 ± 5585176.199 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 100 10000 avgt 10 16.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 100 10000 avgt 10 176.000 ms
SqlNodeToRelBenchmark.convertToRel 1000 10000 avgt 10 4987.583 ± 239.764 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 1000 10000 avgt 10 350.407 ± 15.358 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 1000 10000 avgt 10 4453949143.200 ± 15691.941 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 1000 10000 avgt 10 348.994 ± 26.380 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 1000 10000 avgt 10 4435948339.200 ± 266086966.795 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Old_Gen 1000 10000 avgt 10 1.893 ± 6.349 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Old_Gen.norm 1000 10000 avgt 10 24367208.000 ± 81472991.298 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 1000 10000 avgt 10 1.660 ± 1.751 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 1000 10000 avgt 10 21105067.200 ± 22178668.452 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 1000 10000 avgt 10 73.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 1000 10000 avgt 10 774.000
{noformat}
After
{noformat}
Benchmark (columnLength) (length) Mode Cnt Score Error Units
SqlNodeToRelBenchmark.convertToRel 10 10000 avgt 10 288.835 ± 20.252 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 10 10000 avgt 10 459.374 ± 18.519 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 10 10000 avgt 10 659938760.000 ± 49428.089 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 10 10000 avgt 10 490.775 ± 210.971 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 10 10000 avgt 10 704897644.800 ± 301605807.670 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 10 10000 avgt 10 1.574 ± 3.374 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 10 10000 avgt 10 2252962.400 ± 4762926.396 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 10 10000 avgt 10 11.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 10 10000 avgt 10 154.000 ms
SqlNodeToRelBenchmark.convertToRel 100 10000 avgt 10 509.465 ± 74.283 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 100 10000 avgt 10 303.838 ± 14.327 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 100 10000 avgt 10 676153652.800 ± 15704.126 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 100 10000 avgt 10 314.323 ± 170.464 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 100 10000 avgt 10 699505049.600 ± 378398909.943 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Old_Gen 100 10000 avgt 10 3.137 ± 14.996 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Old_Gen.norm 100 10000 avgt 10 7220859.200 ± 34522296.631 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 100 10000 avgt 10 3.042 ± 8.092 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 100 10000 avgt 10 6922900.800 ± 18650918.876 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 100 10000 avgt 10 13.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 100 10000 avgt 10 336.000 ms
SqlNodeToRelBenchmark.convertToRel 1000 10000 avgt 10 2701.474 ± 85.048 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 1000 10000 avgt 10 66.516 ± 1.464 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 1000 10000 avgt 10 681003708.800 ± 15677.962 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 1000 10000 avgt 10 68.147 ± 9.733 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 1000 10000 avgt 10 697487564.800 ± 94611175.565 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 1000 10000 avgt 10 1.778 ± 0.766 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 1000 10000 avgt 10 18234628.800 ± 8065659.854 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 1000 10000 avgt 10 62.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 1000 10000 avgt 10 591.000 {noformat}
To Summarize ( Benchmark for memoization)
Before change( 10, 100, 1000 column length)
Score Sql To Rel - 856.562 , 1722.243, 11692.547
Score SqlNode to Rel - 303.435, 649.239 , 4987.583
After Change
Score Sql To Rel - 1097.489, 1574.153, 8805.355
Score SqlNode to Rel - 288.835, 509.465, 2701.474
We can see that we are 25% faster in Sql To Rel, infact as the query complexity and number of columns increases the perf diff increases
We can see that here we are almost 2x faster at column Length = 1000 in SqlNode To Rel
What do you think about this?
should I run the same benchmark with the Func approach too?( might need to change some code around correlation which I am not that familiar)
was (Author: jaynarale):
[~julianhyde]
1. Here is the benchmark done from SqlString to Rel
Before Change
{noformat}
Benchmark (columnLength) (length) Mode Cnt Score Error Units
SqlToRelBenchmark.parse 10 10000 avgt 10 856.562 ± 38.717 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 10 10000 avgt 10 483.733 ± 13.833 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 10 10000 avgt 10 701324085.600 ± 39465.820 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 10 10000 avgt 10 476.272 ± 203.095 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 10 10000 avgt 10 691588300.800 ± 304688028.003 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 10 10000 avgt 10 2.684 ± 3.198 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 10 10000 avgt 10 3905840.000 ± 4698628.651 B/op
SqlToRelBenchmark.parse:·gc.count 10 10000 avgt 10 11.000 counts
SqlToRelBenchmark.parse:·gc.time 10 10000 avgt 10 115.000 ms
SqlToRelBenchmark.parse 100 10000 avgt 10 1722.243 ± 52.744 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 100 10000 avgt 10 429.921 ± 9.949 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 100 10000 avgt 10 1015519904.000 ± 1464061.426 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 100 10000 avgt 10 427.008 ± 215.019 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 100 10000 avgt 10 1004745523.200 ± 489941534.693 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 100 10000 avgt 10 2.748 ± 2.065 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 100 10000 avgt 10 6497039.200 ± 4893463.920 B/op
SqlToRelBenchmark.parse:·gc.count 100 10000 avgt 10 16.000 counts
SqlToRelBenchmark.parse:·gc.time 100 10000 avgt 10 169.000 ms
SqlToRelBenchmark.parse 1000 10000 avgt 10 11692.547 ± 851.444 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 1000 10000 avgt 10 348.097 ± 23.548 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 1000 10000 avgt 10 4452909090.400 ± 15612.795 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 1000 10000 avgt 10 351.376 ± 41.195 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 1000 10000 avgt 10 4495664742.400 ± 441960646.820 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Old_Gen 1000 10000 avgt 10 1.736 ± 6.089 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Old_Gen.norm 1000 10000 avgt 10 22115972.000 ± 76405252.332 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 1000 10000 avgt 10 2.004 ± 1.353 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 1000 10000 avgt 10 25541660.800 ± 18005770.534 B/op
SqlToRelBenchmark.parse:·gc.count 1000 10000 avgt 10 75.000 counts
SqlToRelBenchmark.parse:·gc.time 1000 10000 avgt 10 798.000 ms{noformat}
After Change
{noformat}
Benchmark (columnLength) (length) Mode Cnt Score Error Units
SqlToRelBenchmark.parse 10 10000 avgt 10 1097.489 ± 601.332 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 10 10000 avgt 10 410.155 ± 124.156 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 10 10000 avgt 10 668138544.000 ± 20234.919 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 10 10000 avgt 10 400.142 ± 123.542 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 10 10000 avgt 10 651270553.600 ± 6713379.946 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 10 10000 avgt 10 0.760 ± 0.763 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 10 10000 avgt 10 1221336.800 ± 1021068.328 B/op
SqlToRelBenchmark.parse:·gc.count 10 10000 avgt 10 10.000 counts
SqlToRelBenchmark.parse:·gc.time 10 10000 avgt 10 76.000 ms
SqlToRelBenchmark.parse 100 10000 avgt 10 1574.153 ± 37.087 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 100 10000 avgt 10 302.032 ± 5.232 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 100 10000 avgt 10 666304293.600 ± 15652.357 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 100 10000 avgt 10 292.489 ± 2.859 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 100 10000 avgt 10 645293670.400 ± 7166058.122 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 100 10000 avgt 10 0.679 ± 0.471 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 100 10000 avgt 10 1501587.200 ± 1065005.841 B/op
SqlToRelBenchmark.parse:·gc.count 100 10000 avgt 10 10.000 counts
SqlToRelBenchmark.parse:·gc.time 100 10000 avgt 10 59.000 ms
SqlToRelBenchmark.parse 1000 10000 avgt 10 8805.355 ± 81.191 ms/op
SqlToRelBenchmark.parse:·gc.alloc.rate 1000 10000 avgt 10 68.407 ± 0.613 MB/sec
SqlToRelBenchmark.parse:·gc.alloc.rate.norm 1000 10000 avgt 10 669883507.200 ± 15678.613 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space 1000 10000 avgt 10 69.629 ± 11.177 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Eden_Space.norm 1000 10000 avgt 10 681888491.200 ± 109763637.726 B/op
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space 1000 10000 avgt 10 1.946 ± 0.899 MB/sec
SqlToRelBenchmark.parse:·gc.churn.PS_Survivor_Space.norm 1000 10000 avgt 10 19059080.800 ± 8796351.410 B/op
SqlToRelBenchmark.parse:·gc.count 1000 10000 avgt 10 60.000 counts
SqlToRelBenchmark.parse:·gc.time 1000 10000 avgt 10 485.000 {noformat}
2. Here is the benchmark done from SqlNode to RelNode
Before
{noformat}
Benchmark (columnLength) (length) Mode Cnt Score Error Units
SqlNodeToRelBenchmark.convertToRel 10 10000 avgt 10 303.435 ± 45.051 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 10 10000 avgt 10 477.892 ± 29.078 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 10 10000 avgt 10 698375281.600 ± 18118.684 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 10 10000 avgt 10 477.193 ± 206.791 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 10 10000 avgt 10 698613760.000 ± 311974407.144 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 10 10000 avgt 10 2.122 ± 5.715 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 10 10000 avgt 10 3206512.800 ± 8744399.798 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 10 10000 avgt 10 11.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 10 10000 avgt 10 187.000 ms
SqlNodeToRelBenchmark.convertToRel 100 10000 avgt 10 649.239 ± 40.462 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 100 10000 avgt 10 429.163 ± 11.149 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 100 10000 avgt 10 1013260700.000 ± 15640.769 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 100 10000 avgt 10 426.631 ± 214.136 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 100 10000 avgt 10 1003696947.200 ± 488659899.338 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 100 10000 avgt 10 1.852 ± 2.396 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 100 10000 avgt 10 4362263.200 ± 5585176.199 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 100 10000 avgt 10 16.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 100 10000 avgt 10 176.000 ms
SqlNodeToRelBenchmark.convertToRel 1000 10000 avgt 10 4987.583 ± 239.764 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 1000 10000 avgt 10 350.407 ± 15.358 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 1000 10000 avgt 10 4453949143.200 ± 15691.941 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 1000 10000 avgt 10 348.994 ± 26.380 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 1000 10000 avgt 10 4435948339.200 ± 266086966.795 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Old_Gen 1000 10000 avgt 10 1.893 ± 6.349 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Old_Gen.norm 1000 10000 avgt 10 24367208.000 ± 81472991.298 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 1000 10000 avgt 10 1.660 ± 1.751 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 1000 10000 avgt 10 21105067.200 ± 22178668.452 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 1000 10000 avgt 10 73.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 1000 10000 avgt 10 774.000
{noformat}
After
{noformat}
Benchmark (columnLength) (length) Mode Cnt Score Error Units
SqlNodeToRelBenchmark.convertToRel 10 10000 avgt 10 288.835 ± 20.252 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 10 10000 avgt 10 459.374 ± 18.519 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 10 10000 avgt 10 659938760.000 ± 49428.089 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 10 10000 avgt 10 490.775 ± 210.971 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 10 10000 avgt 10 704897644.800 ± 301605807.670 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 10 10000 avgt 10 1.574 ± 3.374 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 10 10000 avgt 10 2252962.400 ± 4762926.396 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 10 10000 avgt 10 11.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 10 10000 avgt 10 154.000 ms
SqlNodeToRelBenchmark.convertToRel 100 10000 avgt 10 509.465 ± 74.283 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 100 10000 avgt 10 303.838 ± 14.327 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 100 10000 avgt 10 676153652.800 ± 15704.126 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 100 10000 avgt 10 314.323 ± 170.464 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 100 10000 avgt 10 699505049.600 ± 378398909.943 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Old_Gen 100 10000 avgt 10 3.137 ± 14.996 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Old_Gen.norm 100 10000 avgt 10 7220859.200 ± 34522296.631 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 100 10000 avgt 10 3.042 ± 8.092 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 100 10000 avgt 10 6922900.800 ± 18650918.876 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 100 10000 avgt 10 13.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 100 10000 avgt 10 336.000 ms
SqlNodeToRelBenchmark.convertToRel 1000 10000 avgt 10 2701.474 ± 85.048 ms/op
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate 1000 10000 avgt 10 66.516 ± 1.464 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.alloc.rate.norm 1000 10000 avgt 10 681003708.800 ± 15677.962 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space 1000 10000 avgt 10 68.147 ± 9.733 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Eden_Space.norm 1000 10000 avgt 10 697487564.800 ± 94611175.565 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space 1000 10000 avgt 10 1.778 ± 0.766 MB/sec
SqlNodeToRelBenchmark.convertToRel:·gc.churn.PS_Survivor_Space.norm 1000 10000 avgt 10 18234628.800 ± 8065659.854 B/op
SqlNodeToRelBenchmark.convertToRel:·gc.count 1000 10000 avgt 10 62.000 counts
SqlNodeToRelBenchmark.convertToRel:·gc.time 1000 10000 avgt 10 591.000 {noformat}
To Summarize ( Benchmark for memoization)
Before change( 10, 100, 1000 column length)
Score Sql To Rel - 856.562 , 1722.243, 11692.547
Score SqlNode to Rel - 303.435, 649.239 , 4987.583
After Change
Score Sql To Rel - 1097.489, 1574.153, 8805.355
Score SqlNode to Rel - 288.835, 509.465, 2701.474
We can see that we are 25% faster in Sql To Rel, infact as the query complexity and number of columns increases the perf diff increases
We can see that here we are almost 2x faster at column Length = 1000 in SqlNode To Rel
What do you think about this?
should I run the same benchmark with the Func approach too?( might need to change some code around correlation which I am not that familiar)
> SqlToRelConverter creates FieldMap for every Identifier Instead of Memoizing it
> -------------------------------------------------------------------------------
>
> Key: CALCITE-4994
> URL: https://issues.apache.org/jira/browse/CALCITE-4994
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Jay Narale
> Priority: Major
> Labels: pull-request-available
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> When converting from Sql To Rel, In SqlToRelConverter for every single instance of an identifier we create a new map in
> *_org.apache.calcite.sql2rel.SqlToRelConverter.Blackboard#lookupExp_*
>
> {code:java}
> final Map<String, Integer> fieldOffsets = new HashMap<>();
> for (RelDataTypeField f : resolve.rowType().getFieldList()) {
> if (!fieldOffsets.containsKey(f.getName())) {
> fieldOffsets.put(f.getName(), f.getIndex());
> }
> }
> final Map<String, Integer> map = ImmutableMap.copyOf(fieldOffsets);{code}
>
> So for a Sql Query
> {code:java}
> SELECT name, nation FROM customer{code}
> We would do the above operation twice.
> Memoization of this information will improve performance.
> In my database, I had observed that for a large table involving 1200 columns and a huge select having multiple expressions and operators, this part was a bottleneck.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)