greptimedb icon indicating copy to clipboard operation
greptimedb copied to clipboard

feat: reduce sorted runs during compaction

Open v0y4g3r opened this issue 10 months ago • 1 comments

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

  • #3416

What's changed and what's your intention?

This PR changes the behavior during compaction from reduce file nums to sorted runs.

A sorted run in GreptimeDB is defined as a sequence of non-overlapping SST files. If multiple sorted runs exist in some time window, even a simple query with explicit time ranges may invole multiple files. Before this PR, GreptimeDB merges all files in active window into one single file if the total num of files exceeds max_active_window_files, of which the write amplification is rather severe. In this PR, we only enforce a max_active_window_runs in active window to reduce read amplication. If num of sorted runs exceeds that threshold, it only merges the overlapping files on demand.

Checklist

  • [x] I have written the necessary rustdoc comments.
  • [x] I have added the necessary unit tests and integration tests.
  • [ ] This PR does not require documentation updates.

v0y4g3r avatar Apr 14 '24 14:04 v0y4g3r

Codecov Report

Attention: Patch coverage is 99.83871% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.67%. Comparing base (b6585e3) to head (f126da3). Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3702      +/-   ##
==========================================
- Coverage   84.89%   84.67%   -0.23%     
==========================================
  Files        1040     1041       +1     
  Lines      183506   184060     +554     
==========================================
+ Hits       155789   155844      +55     
- Misses      27717    28216     +499     

codecov[bot] avatar Apr 26 '24 08:04 codecov[bot]

What's the progress of this PR? @v0y4g3r

killme2008 avatar May 13 '24 12:05 killme2008

@v0y4g3r What's the status of this PR? It's deprecated or just wait for resolving conflicts.

killme2008 avatar Jun 07 '24 23:06 killme2008

[!WARNING]

Rate limit exceeded

@tisonkun has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 49 minutes and 18 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 379cd7159299e9e4fbf32f442950bdd9aa6197bf and f126da33ba1763045e7b4e3cf85bc2b57de8046e.

Walkthrough

The changes primarily revolve around transitioning from file-based to run-based terminology and logic within the compaction mechanism, focusing on improving clarity in file handling and compaction processes. Key modifications include renaming file-related parameters for better representation of run handling, introducing a new module for run management, and updating test cases to align with the new terminology.

Changes

File(s) Change Summary
src/.../compaction.rs Added new run module.
src/.../picker.rs, src/.../twcs.rs Renamed parameters from files to runs and updated compaction logic accordingly.
src/.../run.rs Introduced functionalities for handling sorted runs and merging items, defining related traits and structures.
src/.../append_mode_test.rs, src/.../compaction_test.rs, src/.../filter_deleted_test.rs Updated test cases to use runs terminology and adjusted assertions to reflect the new logic.
src/.../options.rs Renamed struct fields from max_active_window_files to max_active_window_runs and the respective inactive counterparts.
src/.../file.rs Added size method in FileHandle.
src/.../mito_engine_options.rs Updated keys for compaction options from files to runs.
tests/.../create_with_options.result, tests/.../create_with_options.sql Adjusted configuration options and parameters in test scripts to use runs instead of files.

Poem

In the land where code runs free, New 'runs' are born, no longer 'files' to see, Merging smart, and sorted neat, Efficiency in compaction we now greet. Tests revised, all aligned, For a smoother, future-compacted time. 🐰✨


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.

coderabbitai[bot] avatar Jun 27 '24 07:06 coderabbitai[bot]