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

feat(optimizer): grow stack for complicated plan in more places #17224

Merged
merged 4 commits into from
Jun 18, 2024

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Jun 12, 2024

Signed-off-by: Bugen Zhao [email protected]I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Follow-up of #16279. Based on some actual queries provided by users, this PR adopts fearless recursion to more places to provide better support for complicated plan in optimizer, including:

  • Expression visitor / rewriter
  • Plan visitor / rewriter

The theory behind why this will work by only touching the optimizer code may be that, the final physical plan and expression tree executed on the compute nodes could be less complex than what we have to handle in the optimizer, thus requiring less stack depth. This is further because...

  • we have common sub-expression elimination
  • we will cut the plan tree into fragments when executing

However, this still cannot cover those most complicated queries, which will overflows the stack even when calling the compiler-generated Clone impl. The only workaround is to set RUST_STACK_SIZE in that case.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
@BugenZhao BugenZhao marked this pull request as ready for review June 13, 2024 09:41
@BugenZhao BugenZhao requested review from chenzl25 and xxchan June 13, 2024 09:41
Copy link
Contributor

@chenzl25 chenzl25 left a comment

Choose a reason for hiding this comment

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

LGTM!

@chenzl25
Copy link
Contributor

Wondering whether this PR could help for a materialized view with 100 joins without tuning the RUST_STACK_SIZE.

@BugenZhao
Copy link
Member Author

Wondering whether this PR could help for a materialized view with 100 joins without tuning the RUST_STACK_SIZE.

It may vary depending on the optimization level. According to my tests, at least it's still not possible in the debug build. 😢

@BugenZhao BugenZhao added this pull request to the merge queue Jun 18, 2024
Merged via the queue into main with commit ba80ab6 Jun 18, 2024
30 of 31 checks passed
@BugenZhao BugenZhao deleted the bz/expr-stack-overflow branch June 18, 2024 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants