Skip to content

feat(frontend): fearless recursion on deep plans #16279

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

Merged
merged 6 commits into from
Apr 17, 2024
Merged

feat(frontend): fearless recursion on deep plans #16279

merged 6 commits into from
Apr 17, 2024

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Apr 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?

Use stacker to dynamically grow the stack for deep recursion. Check the documentation on the source code for the usage.

Considering that growing the stack may lead to performance overhead, and we may fail to wrap all recursion when handling a deep plan. We warn to users if we find the recursion too deep in to_stream_prost or to_batch_prost.

Hide the whitespaces for better review experience.

Resolve #15916.

dev=> CREATE MATERIALIZED VIEW ..

- stack overflow
+ NOTICE: The plan is too deep. Consider simplifying or splitting the query if you encounter any issues.
+ CREATE_MATERIALIZED_VIEW

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

Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
@BugenZhao BugenZhao requested a review from a team as a code owner April 12, 2024 08:28
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.

Looks very cool! A common case of stack overflow is Lots of Unions, e.g. select 1 union all select 1 ..... union all select, Could you please test against it whether this PR could help?

@BugenZhao
Copy link
Member Author

A common case of stack overflow is Lots of Unions, e.g. select 1 union all select 1 ..... union all select, Could you please test against it whether this PR could help?

Unfortunately not. 😕 I guess the most heaviest part of this query resides in other steps (like parsing or optimization), which are not covered in this PR. We have to find them out and wrap them with recurse in a progressive manner.

@BugenZhao
Copy link
Member Author

We have to find them out and wrap them with recurse in a progressive manner.

Will do this in following PRs.

Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
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!

Copy link
Member

@stdrc stdrc left a comment

Choose a reason for hiding this comment

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

LGTM, Ancient Greek God of Recursion!

Copy link
Contributor

@TennyZhuang TennyZhuang left a comment

Choose a reason for hiding this comment

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

LGTM.

BTW, IIRC in TiKV, the recursion limit of plan always exceeded when encode/decode from/to protobuf. To resolve that, they use reverse polish notation in the plan proto definitions.

@BugenZhao BugenZhao added this pull request to the merge queue Apr 17, 2024
Merged via the queue into main with commit 32df9cb Apr 17, 2024
27 of 28 checks passed
@BugenZhao BugenZhao deleted the bz/recursive branch April 17, 2024 02:50
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.

frontend stack overflow when calling to_stream_prost on a complex query
5 participants