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

Change compaction_readahead_size default value to 2MB #11762

Closed
wants to merge 1 commit into from

Conversation

hx235
Copy link
Contributor

@hx235 hx235 commented Aug 25, 2023

Context/Summary:
After #11631, we rely on compaction_readahead_size for how much to read ahead for compaction read under non-direct IO case. #11658 therefore also sanitized 0 compaction_readahead_size to 2MB under non-direct IO, which is consistent with the existing sanitization with direct IO.

However, this makes disabling compaction readahead impossible as well as add one more scenario to the inconsistent effects between Options.compaction_readahead_size=0 during DB open and SetDBOptions("compaction_readahead_size", "0") .

  • SetDBOptions("compaction_readahead_size", "0") will disable compaction readahead as its logic never goes through sanitization above while Options.compaction_readahead_size=0 will go through sanitization.

Therefore we decided to do this PR.

Test:
Modified existing UTs to cover this PR

Comment on lines 301 to 302
if (db_options.compaction_readahead_size == 0) {
return Status::InvalidArgument(
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this cause any existing options files to fail validation? Should the "Sanitize" code also be changed to say that if the value is 0, set it to the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point - let me think more about it

@hx235 hx235 added the WIP Work in progress label Aug 28, 2023
@hx235 hx235 closed this Aug 28, 2023
@hx235 hx235 reopened this Aug 28, 2023
@hx235 hx235 force-pushed the compaction_readahead_size_option branch 2 times, most recently from 7f83aaf to 268c2d1 Compare August 28, 2023 22:18
@hx235 hx235 changed the title Change default value + validation during SetDBOptions() for compaction_readahead_size Change default value to use special sentinel for compaction_readahead_size Aug 28, 2023
@hx235 hx235 changed the title Change default value to use special sentinel for compaction_readahead_size Change compaction_readahead_size default value and add more sanitization logic on value 0 Aug 28, 2023
@hx235 hx235 changed the title Change compaction_readahead_size default value and add more sanitization logic on value 0 Change compaction_readahead_size default value with more sanitization logic on value 0 Aug 28, 2023
@hx235 hx235 force-pushed the compaction_readahead_size_option branch from 268c2d1 to 8ae0ab8 Compare August 28, 2023 22:34
@facebook-github-bot
Copy link
Contributor

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

@hx235 hx235 force-pushed the compaction_readahead_size_option branch from 8ae0ab8 to c683317 Compare August 28, 2023 22:51
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@hx235 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.

Have you considered not doing sanitization during DB open and instead applying the default when it is used? CompressionOptions::level (see compression functions like ZSTD_Compress()) and ColumnFamilyOptions::max_background_{jobs,flushes,compactions} (see GetBGJobLimits()) do this

include/rocksdb/options.h Outdated Show resolved Hide resolved
include/rocksdb/options.h Outdated Show resolved Hide resolved
db/db_impl/db_impl_open.cc Outdated Show resolved Hide resolved
@hx235 hx235 force-pushed the compaction_readahead_size_option branch from c683317 to d12892f Compare August 29, 2023 21:34
@hx235 hx235 changed the title Change compaction_readahead_size default value with more sanitization logic on value 0 Change compaction_readahead_size default value to 2MB Aug 29, 2023
@facebook-github-bot
Copy link
Contributor

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

@hx235 hx235 force-pushed the compaction_readahead_size_option branch from d12892f to 80fe865 Compare August 29, 2023 22:36
@facebook-github-bot
Copy link
Contributor

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

@hx235 hx235 force-pushed the compaction_readahead_size_option branch from 80fe865 to 51a5438 Compare August 29, 2023 23:24
@facebook-github-bot
Copy link
Contributor

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

@hx235 hx235 force-pushed the compaction_readahead_size_option branch from 51a5438 to 39f15a5 Compare August 29, 2023 23:25
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@hx235 hx235 requested review from ajkr and anand1976 August 30, 2023 00:52
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

@@ -0,0 +1 @@
As `Options::access_hint_on_compaction_start` is made to have no effect since #11658, under non-direct IO, setting `Options::compaction_readahead_size` to 0 may regress compaction read performance, because it will not have the readahead issued by Kernel, which is the behavior prior to #11658, nor the intended replacement of Kernel-issued readahead by RocksDB-issued readahead introduced in #11631 now requiring `Options::compaction_readahead_size > 0`
Copy link
Contributor

@ajkr ajkr Aug 30, 2023

Choose a reason for hiding this comment

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

How about "compaction read performance will regress when Options::compaction_readahead_size is explicitly set to 0"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@hx235 hx235 force-pushed the compaction_readahead_size_option branch from 39f15a5 to 59555e6 Compare August 30, 2023 16:24
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@hx235 hx235 force-pushed the compaction_readahead_size_option branch from 59555e6 to 653eeaf Compare August 30, 2023 19:50
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@hx235 hx235 force-pushed the compaction_readahead_size_option branch from 653eeaf to eb69853 Compare August 30, 2023 19:53
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@hx235 merged this pull request in 05daa12.

hx235 added a commit that referenced this pull request Aug 30, 2023
Summary:
**Context/Summary:**
After #11631, we rely on `compaction_readahead_size` for how much to read ahead for compaction read under non-direct IO case. #11658 therefore also sanitized 0 `compaction_readahead_size` to 2MB under non-direct IO, which is consistent with the existing sanitization with direct IO.

However, this makes disabling compaction readahead impossible as well as add one more scenario to the inconsistent effects between `Options.compaction_readahead_size=0` during DB open and `SetDBOptions("compaction_readahead_size", "0")` .
- `SetDBOptions("compaction_readahead_size", "0")` will disable compaction readahead as its logic never goes through sanitization above while `Options.compaction_readahead_size=0` will go through sanitization.

Therefore we decided to do this PR.

Pull Request resolved: #11762

Test Plan: Modified existing UTs to cover this PR

Reviewed By: ajkr

Differential Revision: D48759560

Pulled By: hx235

fbshipit-source-id: b3f85e58bda362a6fa1dc26bd8a87aa0e171af79
alexanderkiel added a commit to alexanderkiel/rocksdb that referenced this pull request Nov 22, 2023
Recently in facebook#11762 the default of `compaction_readahead_size` changed
from 0 to 2 MB.

Closes: facebook#12088
facebook-github-bot pushed a commit that referenced this pull request Nov 27, 2023
Summary:
Recently in #11762 the default of `compaction_readahead_size` changed from 0 to 2 MB.

Closes: #12088

Pull Request resolved: #12090

Reviewed By: jaykorean

Differential Revision: D51531762

Pulled By: ajkr

fbshipit-source-id: a0b7145a1dca95ee90ffa3553f6eeacce6424aee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants