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: Partition memtables by time if compaction window is provided #3501

Merged
merged 15 commits into from Mar 14, 2024

Conversation

evenyag
Copy link
Contributor

@evenyag evenyag commented Mar 13, 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 introduces a new struct TimePartitions to partition mutable memtables by time.

  • It uses the compaction time window (compaction.twcs.time_window) as the partition time range
  • Each partition holds timestamps between [start_time, start_time + time_window)
  • We uses the timestamp / time_window * time_window to locate the proper partition
  • If the compaction time window is not provided, it only has one partition and all timestamps belong to that partition
  • Once we freeze a memtable version, we move all memtables in TimePartitions to immutable memtable list.

With this feature, a region can strictly divide data by the time in memory. It also ensures flushed SSTs only belong to a single time window.

Checklist

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

@github-actions github-actions bot added the Doc not needed This PR do not impact docs label Mar 13, 2024
@evenyag evenyag marked this pull request as ready for review March 13, 2024 11:08
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 90.60773% with 51 lines in your changes are missing coverage. Please review.

Project coverage is 84.95%. Comparing base (58bd065) to head (759e84a).
Report is 6 commits behind head on main.

❗ Current head 759e84a differs from pull request most recent head eda062f. Consider uploading reports for the commit eda062f to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3501      +/-   ##
==========================================
- Coverage   85.35%   84.95%   -0.41%     
==========================================
  Files         903      905       +2     
  Lines      149639   150400     +761     
==========================================
+ Hits       127726   127770      +44     
- Misses      21913    22630     +717     

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

Copy link
Contributor

@v0y4g3r v0y4g3r left a comment

Choose a reason for hiding this comment

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

LGTM

@v0y4g3r v0y4g3r enabled auto-merge March 14, 2024 11:01
@v0y4g3r v0y4g3r added this pull request to the merge queue Mar 14, 2024
Merged via the queue into GreptimeTeam:main with commit 8ca9e01 Mar 14, 2024
17 checks passed
@v0y4g3r v0y4g3r deleted the feat/partition-memtable branch March 14, 2024 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Doc not needed This PR do not impact docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants