-
Notifications
You must be signed in to change notification settings - Fork 334
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!: reduce sorted runs during compaction #3702
Conversation
2c0f146
to
2dc724e
Compare
f43d397
to
0dd58a5
Compare
0dd58a5
to
b4e29b9
Compare
Codecov ReportAttention: Patch coverage is
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
What's the progress of this PR? @v0y4g3r |
@v0y4g3r What's the status of this PR? It's deprecated or just wait for resolving conflicts. |
Refactor compaction logic and update test configurations - Refactored `merge_all_runs` function to use `sort_ranged_items` for sorting. - Improved item merging logic by iterating with `into_iter` and handling overlaps. - Updated test configurations to use `max_active_window_runs` instead of `max_active_window_files` for consistency.
504399b
to
379cd71
Compare
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 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. WalkthroughThe 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
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (12)
- src/mito2/src/compaction.rs (1 hunks)
- src/mito2/src/compaction/picker.rs (1 hunks)
- src/mito2/src/compaction/run.rs (1 hunks)
- src/mito2/src/compaction/twcs.rs (3 hunks)
- src/mito2/src/engine/append_mode_test.rs (2 hunks)
- src/mito2/src/engine/compaction_test.rs (7 hunks)
- src/mito2/src/engine/filter_deleted_test.rs (1 hunks)
- src/mito2/src/region/options.rs (6 hunks)
- src/mito2/src/sst/file.rs (1 hunks)
- src/store-api/src/mito_engine_options.rs (2 hunks)
- tests/cases/standalone/common/create/create_with_options.result (2 hunks)
- tests/cases/standalone/common/create/create_with_options.sql (2 hunks)
Files skipped from review due to trivial changes (1)
- src/mito2/src/compaction.rs
Additional comments not posted (15)
tests/cases/standalone/common/create/create_with_options.sql (1)
60-61
: Correct option values for window runs.The options
max_active_window_runs
andmax_inactive_window_runs
are correctly set to '2' which aligns with the new run-based compaction logic.tests/cases/standalone/common/create/create_with_options.result (1)
70-71
: Correct option values for window runs.The options
max_active_window_runs
andmax_inactive_window_runs
are correctly set to '2' which aligns with the new run-based compaction logic.src/store-api/src/mito_engine_options.rs (1)
25-26
: Updated option keys for run-based compaction.The addition of
max_active_window_runs
andmax_inactive_window_runs
to the list of valid option keys aligns with the new run-based compaction logic. The changes are correctly implemented in the function.Also applies to: 50-53
src/mito2/src/engine/filter_deleted_test.rs (1)
37-37
: Updated test to include new compaction option.The inclusion of the
max_active_window_runs
option in the test setup aligns with the new run-based compaction logic. The test is correctly updated to reflect the expected behavior.src/mito2/src/engine/append_mode_test.rs (1)
103-104
: Updated test to include new compaction options.The inclusion of the
max_active_window_runs
andmax_inactive_window_runs
options in the test setup aligns with the new run-based compaction logic. The test is correctly updated to reflect the expected behavior.src/mito2/src/compaction/picker.rs (1)
135-136
: Updated parameter names to reflect run-based terminology.The function
new_picker
now correctly usesmax_active_window_runs
andmax_inactive_window_runs
as parameters. This change aligns with the PR's objective to shift from file-based to run-based compaction metrics. Ensure that all references to these parameters across the system are consistently updated.src/mito2/src/sst/file.rs (1)
204-206
: Added a method to retrieve file size.The new
size
method in theFileHandle
class provides a way to retrieve the file size, which is essential for making informed decisions during compaction processes. This is a straightforward addition and correctly implements the functionality.src/mito2/src/engine/compaction_test.rs (2)
174-175
: Updated compaction configuration keys in test cases.The test cases have been updated to use the new run-based configuration keys:
max_active_window_runs
andmax_inactive_window_runs
. This ensures that the tests align with the new compaction strategy and are testing the system under the correct configuration.Also applies to: 218-219, 280-280
294-294
: Ensure overlapping handling in compaction tests.The test case
test_compaction_region_with_overlapping
introduces overlapping time windows to verify the compaction logic. This is crucial for testing the robustness of the new compaction strategy under complex scenarios.src/mito2/src/region/options.rs (2)
135-138
: UpdatedTwcsOptions
to use run-based terminology.The
TwcsOptions
struct now usesmax_active_window_runs
andmax_inactive_window_runs
instead of the previous file-based terminology. This change is consistent with the overarching theme of the PR and correctly reflects the new compaction strategy.
163-164
: Default values forTwcsOptions
.The default values for
max_active_window_runs
andmax_inactive_window_runs
have been set to 1. This change is reasonable, assuming a conservative default setting is desired until tuned by actual system usage or configuration.src/mito2/src/compaction/twcs.rs (4)
32-32
: Good introduction of a constant for compaction level.Using a constant for the compaction level improves code maintainability and readability by avoiding magic numbers.
37-59
: Struct and constructor updates are consistent with new terminology.The changes to the
TwcsPicker
struct and its constructor method are consistent with the shift from file-based to run-based compaction logic.
65-101
: Ensure comprehensive handling of runs inbuild_output
.The
build_output
method has been significantly refactored to handle runs instead of files. Ensure that this method correctly handles edge cases, such as when there are no active windows or when the number of runs is already within the allowed limit. The use offind_sorted_runs
andreduce_runs
should be closely monitored in integration tests to ensure they function as expected.Consider adding more detailed logging within the
build_output
method to aid in debugging and monitoring the compaction process.
138-140
: Review the handling of file assignments inpick
.The
pick
method has been updated to handle the assignment of files to windows. Ensure that the logic for assigning files and handling expired SSTs is correct and robust, especially in edge cases where timestamp calculations might be complex.Consider improving the robustness of timestamp calculations and handling in the
pick
method to prevent potential issues in edge cases.
* feat: add functions to find and merge sorted runs * chore: refactor code * chore: remove some duplicates * chore: remove one clone * refactor: change max_active_window_files to max_active_window_runs * feat: integrate with sorted runs * fix: unit tests * feat: limit num of sorted runs during compaction * fix: some test * fix: some cr comments * feat: use smallvec * chore: rebase main * feat/reduce-sorted-runs: Refactor compaction logic and update test configurations - Refactored `merge_all_runs` function to use `sort_ranged_items` for sorting. - Improved item merging logic by iterating with `into_iter` and handling overlaps. - Updated test configurations to use `max_active_window_runs` instead of `max_active_window_files` for consistency. --------- Co-authored-by: tison <[email protected]>
* feat: add functions to find and merge sorted runs * chore: refactor code * chore: remove some duplicates * chore: remove one clone * refactor: change max_active_window_files to max_active_window_runs * feat: integrate with sorted runs * fix: unit tests * feat: limit num of sorted runs during compaction * fix: some test * fix: some cr comments * feat: use smallvec * chore: rebase main * feat/reduce-sorted-runs: Refactor compaction logic and update test configurations - Refactored `merge_all_runs` function to use `sort_ranged_items` for sorting. - Improved item merging logic by iterating with `into_iter` and handling overlaps. - Updated test configurations to use `max_active_window_runs` instead of `max_active_window_files` for consistency. --------- Co-authored-by: tison <[email protected]>
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 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 amax_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
Summary by CodeRabbit
New Features
run
module.Improvements
max_active_window_files
andmax_inactive_window_files
tomax_active_window_runs
andmax_inactive_window_runs
for clarity.Bug Fixes