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

perf: fine–tuned plan steps #4258

Merged
merged 6 commits into from
Jul 12, 2024
Merged

Conversation

waynexia
Copy link
Member

@waynexia waynexia commented Jul 3, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

!!! DO NOT LEAVE THIS BLOCK EMPTY !!!

Please explain IN DETAIL what the changes are in this PR and why they are needed:

  • Summarize your change (mandatory)
  • How does this PR work? Need a brief introduction for the changed logic (optional)
  • Describe clearly one logical change and avoid lazy messages (optional)
  • Describe any limitations of the current code (optional)

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

  • Updates

    • Changed repository URLs for dependencies to a new source, ensuring continued integration with updated revisions.
  • Enhancements

    • Improved logical plan optimization for better performance in executing queries.
    • Enhanced the physical plan creation process for more efficient query execution.

Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Walkthrough

The recent changes encompass updating the Cargo.toml file to switch the repository URLs for multiple datafusion dependencies from the Apache repository to waynexia/arrow-datafusion. Additionally, the datafusion.rs and planner.rs files in the src/query/src/dist_plan directory have been modified to enhance the optimization processes for logical plans and to update the handling of Explain plans and MergeScan.

Changes

File Change Summary
Cargo.toml Changed repository URLs for datafusion and related dependencies to waynexia/arrow-datafusion.
src/query/src/datafusion.rs Added MergeScanLogicalPlan import and modified handling of Explain plans and logical plan optimization.
src/query/src/dist_plan/planner.rs Refactored optimize_input_logical_plan to optimize directly without explicit Analyzer and updated create_physical_plan.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant DistExtensionPlanner
    participant SessionState
    participant LogicalPlan
    participant PhysicalPlan

    Client->>DistExtensionPlanner: Call optimize_input_logical_plan
    DistExtensionPlanner->>SessionState: Use session_state
    DistExtensionPlanner->>LogicalPlan: Optimize input logical plan
    LogicalPlan-->>DistExtensionPlanner: Return optimized plan
    
    Client->>DistExtensionPlanner: Call create_physical_plan
    DistExtensionPlanner->>OptimizedPlan: Use optimized plan
    OptimizedPlan-->>PhysicalPlan: Create physical plan
    PhysicalPlan-->>DistExtensionPlanner: Return physical plan
    DistExtensionPlanner-->>Client: Return result
Loading

Poem

In the code, new paths align,
From Apache to Wayne's design,
Optimized with careful thread,
Logical plans now forge ahead.
Arrows in the data's flight,
Merge and scan, our plans delight! 🚀🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jul 3, 2024
Signed-off-by: Ruihang Xia <[email protected]>
Signed-off-by: Ruihang Xia <[email protected]>
Signed-off-by: Ruihang Xia <[email protected]>
Signed-off-by: Ruihang Xia <[email protected]>
@waynexia waynexia marked this pull request as ready for review July 11, 2024 12:37
@waynexia waynexia requested review from evenyag and a team as code owners July 11, 2024 12:37
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
Cargo.toml (1)

107-115: Issues found with the revision hashes in Cargo.toml

The specified revision hash d7bda5c9b762426e81f144296deadc87e5f4a0b8 for the datafusion dependencies does not match any commit in the waynexia/arrow-datafusion repository. Please verify and update the revision hashes to ensure they are correct.

  • Files/Lines impacted:
    • Cargo.toml, lines 107-115
Analysis chain

LGTM! Updated repository URLs for datafusion dependencies.

The changes to update the repository URLs of several datafusion dependencies from the Apache repository to the waynexia/arrow-datafusion repository are approved.

However, ensure that the updated revision hashes are correct.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the revision hashes of the updated `datafusion` dependencies.

# Test: Fetch the latest commit hashes from the `waynexia/arrow-datafusion` repository.
# Expect: The fetched hashes should match the updated revision hashes in `Cargo.toml`.

repos=(
  "datafusion"
  "datafusion-common"
  "datafusion-expr"
  "datafusion-functions"
  "datafusion-optimizer"
  "datafusion-physical-expr"
  "datafusion-physical-plan"
  "datafusion-sql"
  "datafusion-substrait"
)

for repo in "${repos[@]}"; do
  git ls-remote https://github.com/waynexia/arrow-datafusion.git HEAD
done

Length of output: 1496


Script:

#!/bin/bash
# Description: Verify the specific revision hashes of the updated `datafusion` dependencies in Cargo.toml.

dependencies=(
  "datafusion"
  "datafusion-common"
  "datafusion-expr"
  "datafusion-functions"
  "datafusion-optimizer"
  "datafusion-physical-expr"
  "datafusion-physical-plan"
  "datafusion-sql"
  "datafusion-substrait"
)

# Expected revision hash from Cargo.toml
expected_hash="d7bda5c9b762426e81f144296deadc87e5f4a0b8"

# Function to get the commit hash for a specific revision
get_commit_hash() {
  local repo_url=$1
  local revision=$2
  git ls-remote $repo_url $revision | awk '{print $1}'
}

# Check each dependency
for dep in "${dependencies[@]}"; do
  repo_url="https://github.com/waynexia/arrow-datafusion.git"
  commit_hash=$(get_commit_hash $repo_url $expected_hash)
  echo "$dep: $commit_hash"
done

Length of output: 4966

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between da0c840 and adb102f.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (3)
  • Cargo.toml (1 hunks)
  • src/query/src/datafusion.rs (2 hunks)
  • src/query/src/dist_plan/planner.rs (4 hunks)
Additional comments not posted (5)
src/query/src/dist_plan/planner.rs (2)

140-147: LGTM! Direct optimization of the input logical plan.

The changes to optimize the input logical plan directly without using an explicit Analyzer are approved.


Line range hint 377-411: LGTM! Improved handling of Explain plans and MergeScan optimization.

The changes to take the optimized plan by reference and the improved handling of Explain plans and MergeScan optimization are approved.

src/query/src/datafusion.rs (3)

51-51: LGTM! Added import for MergeScanLogicalPlan.

The addition of the import for MergeScanLogicalPlan is approved.


377-411: LGTM! Improved handling of Explain plans and MergeScan optimization.

The changes to handle Explain plans and optimize logical plans for MergeScan are approved.


395-407: LGTM! Skipped optimization for MergeScan plans.

The changes to skip optimization for MergeScan plans are approved.

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

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

Project coverage is 84.91%. Comparing base (da0c840) to head (adb102f).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4258      +/-   ##
==========================================
- Coverage   85.18%   84.91%   -0.27%     
==========================================
  Files        1060     1060              
  Lines      189069   189092      +23     
==========================================
- Hits       161057   160571     -486     
- Misses      28012    28521     +509     

Copy link
Contributor

@evenyag evenyag left a comment

Choose a reason for hiding this comment

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

I guess I know what it does.

@waynexia waynexia enabled auto-merge July 12, 2024 06:42
Copy link
Collaborator

@fengjiachun fengjiachun left a comment

Choose a reason for hiding this comment

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

LGTM

@waynexia waynexia added this pull request to the merge queue Jul 12, 2024
Merged via the queue into GreptimeTeam:main with commit 63acc30 Jul 12, 2024
55 checks passed
@waynexia waynexia deleted the optimize-optimizer branch July 12, 2024 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants