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: skip caching uncompressed pages if they are large #4705

Merged
merged 23 commits into from
Sep 10, 2024

Conversation

evenyag
Copy link
Contributor

@evenyag evenyag commented Sep 9, 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?

This PR skips caching uncompressed pages for a column in a row group if it has multiple uncompressed pages. Since caching uncompressed pages for this column may be memory inefficient and decompressing all pages may be slower than only decompress pages on demand.

It also prints more information to logs and explain outputs.

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

  • New Features

    • Introduced a new caching mechanism with enhanced clarity and usability through updated structures and methods.
    • Added a metric for tracking fetch time in the metrics module.
    • Implemented a method to calculate the total number of files in the ScanPartList struct.
  • Bug Fixes

    • Improved logging for sequence scan operations to enhance traceability and observability.
  • Documentation

    • Updated documentation comments for clarity on the purpose of various components.
  • Style

    • Enhanced output formatting for execution plans to improve clarity without affecting functionality.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Sep 9, 2024
Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@evenyag evenyag marked this pull request as ready for review September 10, 2024 08:36
@evenyag evenyag requested review from v0y4g3r and a team as code owners September 10, 2024 08:36
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 74.84277% with 40 lines in your changes missing coverage. Please review.

Project coverage is 84.53%. Comparing base (04de3ed) to head (148ffff).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4705      +/-   ##
==========================================
- Coverage   84.81%   84.53%   -0.28%     
==========================================
  Files        1113     1113              
  Lines      200467   200550      +83     
==========================================
- Hits       170022   169540     -482     
- Misses      30445    31010     +565     

@evenyag
Copy link
Contributor Author

evenyag commented Sep 10, 2024

@coderabbitai summary

Copy link
Contributor

coderabbitai bot commented Sep 10, 2024

Actions performed

Summary regeneration triggered.

Copy link
Contributor

coderabbitai bot commented Sep 10, 2024

Walkthrough

The changes involve significant modifications to the caching mechanism, metrics tracking, and logging within the codebase. Key updates include the renaming of structures and enums for clarity, the introduction of new methods for creating instances, and enhancements to metrics for better performance monitoring. Additionally, the output formatting of execution plans has been adjusted for consistency. These changes collectively aim to improve code clarity, usability, and observability across various components.

Changes

Files Change Summary
src/mito2/src/cache.rs Renamed PageKey to ColumnPagePath, introduced PageKey enum with variants, modified PageValue struct, and adjusted size calculations.
src/mito2/src/metrics.rs Added a new public static reference READ_STAGE_FETCH_PAGES for tracking page fetch metrics.
src/mito2/src/read/merge.rs Enhanced Drop implementation of MergeReader to include a new metric for fetch cost.
src/mito2/src/read/scan_region.rs Added num_files method to ScanPartList and modified num_file_ranges logic for accurate file counting.
src/mito2/src/read/seq_scan.rs Enhanced debug logging to include compaction parameter in various log messages.
src/mito2/src/read/unordered_scan.rs Improved logging in UnorderedScan and UnorderedDistributor, removed unnecessary blank lines, and updated logging macro.
src/mito2/src/sst/parquet.rs Updated tests to use factory methods for PageKey creation, improving clarity in cache operations.
src/mito2/src/sst/parquet/page_reader.rs Refactored CachedPageReader to RowGroupCachedReader, updated method names and documentation for clarity.
src/mito2/src/sst/parquet/row_group.rs Renamed column_cached_pages to column_uncompressed_pages, updated caching logic, and added a new helper function for caching decisions.
tests/cases/distributed/explain/analyze.result Minor output formatting change in SeqScan execution plan.
tests/cases/standalone/common/aggregate/multi_regions.result Minor output formatting change in SeqScan execution details.
tests/cases/standalone/common/range/nest.result Minor output formatting change in SQL execution plan.
tests/cases/standalone/common/select/prune.result Minor output formatting change in query execution plan.
tests/cases/standalone/tql-explain-analyze/analyze.result Minor output formatting change in SeqScan execution plan.
tests/cases/standalone/optimizer/last_value.result Minor output formatting change in SeqScan execution plan.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Cache
    participant Metrics
    participant Reader

    User->>Cache: Request Page
    Cache->>Reader: Fetch Page
    Reader->>Metrics: Record Fetch Cost
    Metrics-->>Cache: Provide Metrics
    Cache-->>User: Return Page
Loading

🐰 "In the code where rabbits hop,
Changes made, we’ll never stop!
With clearer paths and metrics bright,
Our caching game is now just right!
Let’s celebrate with leaps and cheer,
For better code is finally here!" 🐇✨

Tip

Announcements
  • The review status is no longer posted as a separate comment when there are no actionable or nitpick comments. In such cases, the review status is included in the walkthrough comment.
  • We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs: Walkthrough comment now includes a list of potentially related PRs to help you recall past context. Please share any feedback in the discussion post on our Discord.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs in the walkthrough comment. You can also provide custom labeling instructions in the UI or configuration file.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@waynexia waynexia added this pull request to the merge queue Sep 10, 2024
Merged via the queue into GreptimeTeam:main with commit 3e17c09 Sep 10, 2024
34 checks passed
CookiePieWw pushed a commit to CookiePieWw/greptimedb that referenced this pull request Sep 17, 2024
…#4705)

* feat: cache each uncompressed page

* chore: remove unused function

* chore: log

* chore: log

* chore: row group pages cache kv

* feat: also support row group level cache

* chore: fix range count

* feat: don't cache compressed page for row group cache

* feat: use function to get part

* chore: log whether scan is from compaction

* chore: avoid get column

* feat: add timer metrics

* chore: Revert "feat: add timer metrics"

This reverts commit 4618f57.

* feat: don't cache individual uncompressed page

* feat: append in row group level under append mode

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* chore: fetch pages cost

* perf: yield

* Update src/mito2/src/sst/parquet/row_group.rs

* refactor: cache key

* feat: print file num and row groups num in explain

* test: update sqlness test

* chore: Update src/mito2/src/sst/parquet/page_reader.rs

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
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