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

Clarify usage for options ttl and periodic_compaction_seconds for universal compaction #11552

Closed
wants to merge 4 commits into from

Conversation

cbi42
Copy link
Member

@cbi42 cbi42 commented Jun 22, 2023

Summary: this is stacked on #11550 to further clarify usage of these two options for universal compaction. Similar to FIFO, the two options have the same meaning for universal compaction, which can be confusing to use. For example, for universal compaction, dynamically changing the value of ttl has no impact on periodic compactions. Users should dynamically change periodic_compaction_seconds instead. From feature matrix (https://fburl.com/daiquery/5s647hwh), there are instances where users set ttl to non-zero value and periodic_compaction_seconds to 0. For backward compatibility reason, instead of deprecating ttl, comments are added to mention that periodic_compaction_seconds are preferred. In SanitizeOptions(), we update the value of periodic_compaction_seconds to take into account value of ttl. The logic is documented in relevant option comment.

Test plan:

  • updated existing unit test DBTestUniversalCompaction2.PeriodicCompactionDefault

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!

Comment on lines +403 to +406
if (result.periodic_compaction_seconds == kDefaultPeriodicCompSecs &&
is_block_based_table) {
result.periodic_compaction_seconds = kAdjustedPeriodicCompSecs;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This change (enabling regardless of compaction filter in universal) makes sense to me

Comment on lines +403 to +406
if (result.periodic_compaction_seconds == kDefaultPeriodicCompSecs &&
is_block_based_table) {
result.periodic_compaction_seconds = kAdjustedPeriodicCompSecs;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we should reset result.periodic_compaction_seconds = 0 in case it has a default value and the condition for kAdjustedPeriodicCompSecs is not satisfied (i.e., !is_block_based_table)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's reset to 0 below in lines 427-429, which resets for all compaction styles.

Comment on lines +897 to +899
// Leveled: files older than `periodic_compaction_seconds` will be picked up
// for compaction and will be re-written to the same level as they were
// before.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's only bottom-level files, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's actually for all levels.

// FIFO: not supported. Setting this option has no effect for FIFO compaction.
//
// Universal: when there are files older than `periodic_compaction_seconds`,
// rocksdb will try to do a full compaction if possible. Such compaction
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "full compaction" -> "as large a compaction as possible including the last level"

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, updated.

@cbi42 cbi42 force-pushed the universal-prefer-periodic branch from cb7b648 to e2ddd6f Compare July 11, 2023 21:36
@cbi42 cbi42 marked this pull request as ready for review July 11, 2023 21:36
@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
Copy link
Member Author

cbi42 commented Jul 11, 2023

LGTM!

Thanks for the review! Added change log and imported the PR.

@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 force-pushed the universal-prefer-periodic branch from f96a1e5 to 5853473 Compare July 26, 2023 04:45
@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 5c2a063.

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.

3 participants