Skip to content

Improve expression simplification by running it twice - #3811

Merged
andygrove merged 1 commit into
apache:masterfrom
alamb:alamb/simplify_twice
Oct 12, 2022
Merged

Improve expression simplification by running it twice#3811
andygrove merged 1 commit into
apache:masterfrom
alamb:alamb/simplify_twice

Conversation

@alamb

@alambalamb commented Oct 12, 2022

Copy link
Copy Markdown
Contributor

Draft as it builds on #3741

Which issue does this PR close?

re #3740
re #1160

Rationale for this change

There are some fairly simple expressions that should be simplified but yet are not because additional simplifications are unlocked by the constant propagator.

For example

 (i * 0) > 5

is only simplified to

0 > 5

Because the flow is

  • constant evaluator runs on (i * 0) > 5 which can not do anything,
  • simplfy runs on (i * 0) > 5 and rewrites to 0 > 5

Now, if the constant evaluator can run again it will result in false which is great. However, it is not run again and thus there is the issue.

I hit the same basic embarrassment while making the example in re #1160

The challenges with a fully general solution to this issue are described #1160. However, we have had good luck in IOx simply running the simplification / constant prop twice

What changes are included in this PR?

  1. run evaluator / constant prop twice
  2. Add some more tests

Are there any user-facing changes?

Better constant propagation

@alamb
alambforce-pushed the alamb/simplify_twice branch from 9a85703 to 32b5a76CompareOctober 12, 2022 15:40
@github-actionsgithub-actionsBot added core Core DataFusion crate optimizer Optimizer rules labels Oct 12, 2022
@alamb
alambforce-pushed the alamb/simplify_twice branch from 32b5a76 to 3c3e5b5CompareOctober 12, 2022 17:30
@alamb
alamb marked this pull request as ready for review October 12, 2022 17:30
@alambalamb changed the title Improve simplification by running it twiceImprove expression simplification by running it twiceOct 12, 2022
@github-actionsgithub-actionsBot removed the core Core DataFusion crate label Oct 12, 2022

@andygroveandygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@andygrove
andygrove merged commit 37fe938 into apache:masterOct 12, 2022
@ursabot

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 7179c54 and contender = 37fe938. 37fe938 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@alamb
alamb deleted the alamb/simplify_twice branch August 8, 2023 20:14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizerOptimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@alamb@ursabot@andygrove