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

Delay bottommost level single file compactions #11701

Closed
wants to merge 5 commits into from

Conversation

cbi42
Copy link
Member

@cbi42 cbi42 commented Aug 14, 2023

For leveled compaction, RocksDB has a special kind of compaction with reason "kBottommmostFiles" that compacts bottommost level files to clear data held by snapshots (more detail in #3009). Such compactions can happen soon after a relevant snapshot is released. For some use cases, a bottommost file may contain only a small amount of keys that can be cleared, so compacting such a file has a high write amp. In addition, these bottommost files may be compacted in compactions with reason other than "kBottommmostFiles" if we wait for some time (so that enough data is ingested to trigger such a compaction). This PR introduces an option bottommost_file_compaction_delay to specify the delay of these bottommost level single file compactions.

  • The main change is in VersionStorageInfo::ComputeBottommostFilesMarkedForCompaction() where we only add a file to bottommost_files_marked_for_compaction_ if it oldest_snapshot is larger than its non-zero largest_seqno and the file is old enough. Note that if a file is not old enough but its largest_seqno is less than oldest_snapshot, we exclude it from the calculation of bottommost_files_mark_threshold_. This makes the change simpler, but such a file's eligibility for compaction will only be checked the next time ComputeBottommostFilesMarkedForCompaction() is called. This happens when a new Version is created (compaction, flush, SetOptions()...), a new enough snapshot is released (VersionStorageInfo::UpdateOldestSnapshot()) or when a compaction is picked and compaction score has to be re-calculated.

Test plan:

  • Add two unit tests to test when bottommost_file_compaction_delay > 0.
  • Ran crash test with the new option.

@cbi42 cbi42 force-pushed the delay-bottommost-simpler branch 2 times, most recently from 09016b8 to d329e9b Compare August 14, 2023 20:58
@facebook-github-bot
Copy link
Contributor

@cbi42 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cbi42 has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@cbi42 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@cbi42 cbi42 requested a review from ajkr August 15, 2023 04:50
@jaykorean
Copy link
Contributor

I guess we want to add this to the list of unreleased features.

@cbi42 cbi42 force-pushed the delay-bottommost-simpler branch from 16ac331 to 6abb2cd Compare August 15, 2023 20:25
@cbi42
Copy link
Member Author

cbi42 commented Aug 15, 2023

I guess we want to add this to the list of unreleased features.

Added a note under "new_features".

@facebook-github-bot
Copy link
Contributor

@cbi42 has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@cbi42 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

LGTM!

@cbi42 cbi42 force-pushed the delay-bottommost-simpler branch from 6abb2cd to d8d5fa9 Compare August 16, 2023 20:42
@facebook-github-bot
Copy link
Contributor

@cbi42 has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@cbi42 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cbi42 merged this pull request in d1ff401.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants