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

refactor(cubesql): Move all wrapper replacers params to separate enode #9105

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

mcheshkov
Copy link
Member

@mcheshkov mcheshkov commented Jan 16, 2025

Check List

  • Tests have been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Description of Changes Made (if issue reference is not provided)

Move all repacesr params from WrapperPushdownReplacer and WrapperPullupReplacer to separate node variant WrapperReplacerContext.
Because of the way our current plan_to_language! works, for every non-recusive param in input enum it generates separate wrapper struct on Rust side. So, before this we had separate WrapperPushdownReplacerPushToCube and WrapperPullupReplacerPushToCube. And, because they are separate terminal variants, one can't just copy those in patterns, and had to do it in Rust code, like in transforming_rewrite.

This change allows:

  • Copy context parts between push-down and pull-up replacers directly in patterns
  • Completely ignore context in patterns, like wrapper_pushdown_replacer(cast_expr("?expr", "?data_type"), "?context") => cast_expr(wrapper_pushdown_replacer("?expr", "?context"), "?data_type")
  • Share same eclass with context for a whole replacer stage, instead of one for push-down and one for pullup

All of this simplifies adding new parameters, and have measurable performance boost. On my laptop I measured from about 1 to 11% boost, depending on a benchmark. For example:

power_bi_wrap           time:   [38.386 ms 38.482 ms 38.624 ms]
                        change: [-4.7016% -4.3391% -3.9957%] (p = 0.00 < 0.05)
                        Performance has improved.
...
large_model_1000_select_all_dimensions_with_filter
                        time:   [190.47 ms 190.88 ms 191.17 ms]
                        change: [-12.353% -11.824% -11.374%] (p = 0.00 < 0.05)
                        Performance has improved.

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 99.55357% with 6 lines in your changes missing coverage. Please review.

Project coverage is 83.02%. Comparing base (aab9e8f) to head (4772d35).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...c/compile/rewrite/rules/wrapper/scalar_function.rs 79.31% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9105      +/-   ##
==========================================
- Coverage   83.16%   83.02%   -0.15%     
==========================================
  Files         225      225              
  Lines       80531    79430    -1101     
==========================================
- Hits        66977    65947    -1030     
+ Misses      13554    13483      -71     
Flag Coverage Δ
cubesql 83.02% <99.55%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mcheshkov mcheshkov force-pushed the wrapper-replacer-context branch 2 times, most recently from 685bcb7 to 43d2ef8 Compare January 17, 2025 12:57
@mcheshkov mcheshkov marked this pull request as ready for review January 17, 2025 14:34
@mcheshkov mcheshkov requested a review from a team as a code owner January 17, 2025 14:34
@mcheshkov mcheshkov force-pushed the wrapper-replacer-context branch from 43d2ef8 to 4772d35 Compare January 20, 2025 20:37
@mcheshkov mcheshkov merged commit 9ae9035 into master Jan 20, 2025
68 checks passed
@mcheshkov mcheshkov deleted the wrapper-replacer-context branch January 20, 2025 21:35
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.

2 participants