Prepare for deprecation of Options::access_hint_on_compaction_start (#11658)

Summary:
**Context/Summary:**
After https://github.com/facebook/rocksdb/pull/11631, file hint is not longer needed for compaction read. Therefore we can deprecate `Options::access_hint_on_compaction_start`. As this is a public API change, we should first mark the relevant APIs (including the Java's) deprecated and remove it in next major release 9.0.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11658

Test Plan: No code change

Reviewed By: ajkr

Differential Revision: D47997856

Pulled By: hx235

fbshipit-source-id: 16e015ae7728c224b1caef73143aa9915668f4ac
This commit is contained in:
Hui Xiao 2023-08-03 17:23:02 -07:00 committed by Facebook GitHub Bot
parent 87a21d08fe
commit 09882a52d6
12 changed files with 23 additions and 32 deletions

View File

@ -143,8 +143,10 @@ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src,
result.wal_dir = result.wal_dir.substr(0, result.wal_dir.size() - 1);
}
if (result.use_direct_reads && result.compaction_readahead_size == 0) {
TEST_SYNC_POINT_CALLBACK("SanitizeOptions:direct_io", nullptr);
if (result.compaction_readahead_size == 0) {
if (result.use_direct_reads) {
TEST_SYNC_POINT_CALLBACK("SanitizeOptions:direct_io", nullptr);
}
result.compaction_readahead_size = 1024 * 1024 * 2;
}

View File

@ -1043,7 +1043,8 @@ TEST_F(DBOptionsTest, CompactionReadaheadSizeChange) {
const std::string kValue(1024, 'v');
Reopen(options);
ASSERT_EQ(0, dbfull()->GetDBOptions().compaction_readahead_size);
ASSERT_EQ(1024 * 1024 * 2,
dbfull()->GetDBOptions().compaction_readahead_size);
ASSERT_OK(dbfull()->SetDBOptions({{"compaction_readahead_size", "256"}}));
ASSERT_EQ(256, dbfull()->GetDBOptions().compaction_readahead_size);
for (int i = 0; i < 1024; i++) {

View File

@ -238,16 +238,9 @@ TEST_P(PrefetchTest, Basic) {
fs->ClearPrefetchCount();
} else {
ASSERT_FALSE(fs->IsPrefetchCalled());
if (use_direct_io) {
// To rule out false positive by the SST file tail prefetch during
// compaction output verification
ASSERT_GT(buff_prefetch_count, 1);
} else {
// In buffered IO, compaction readahead size is 0, leading to no prefetch
// during compaction input read
ASSERT_EQ(buff_prefetch_count, 1);
}
// To rule out false positive by the SST file tail prefetch during
// compaction output verification
ASSERT_GT(buff_prefetch_count, 1);
buff_prefetch_count = 0;
ASSERT_GT(cur_table_open_prefetch_tail_read.count,

View File

@ -942,6 +942,9 @@ struct DBOptions {
// Default: null
std::shared_ptr<WriteBufferManager> write_buffer_manager = nullptr;
// DEPRECATED
// This flag has no effect on the behavior of compaction and we plan to delete
// it in the future.
// Specify the file access pattern once a compaction is started.
// It will be applied to all input files of a compaction.
// Default: NORMAL

View File

@ -8,6 +8,7 @@ package org.rocksdb;
/**
* File access pattern once a compaction has started
*/
@Deprecated
public enum AccessHint {
NONE((byte)0x0),
NORMAL((byte)0x1),

View File

@ -752,6 +752,7 @@ public class DBOptions extends RocksObject
}
@Override
@Deprecated
public DBOptions setAccessHintOnCompactionStart(final AccessHint accessHint) {
assert(isOwningHandle());
setAccessHintOnCompactionStart(nativeHandle_, accessHint.getValue());
@ -759,6 +760,7 @@ public class DBOptions extends RocksObject
}
@Override
@Deprecated
public AccessHint accessHintOnCompactionStart() {
assert(isOwningHandle());
return AccessHint.getAccessHint(accessHintOnCompactionStart(nativeHandle_));

View File

@ -935,7 +935,7 @@ public interface DBOptionsInterface<T extends DBOptionsInterface<T>> {
*
* @return the reference to the current options.
*/
T setAccessHintOnCompactionStart(final AccessHint accessHint);
@Deprecated T setAccessHintOnCompactionStart(final AccessHint accessHint);
/**
* Specify the file access pattern once a compaction is started.
@ -945,7 +945,7 @@ public interface DBOptionsInterface<T extends DBOptionsInterface<T>> {
*
* @return The access hint
*/
AccessHint accessHintOnCompactionStart();
@Deprecated AccessHint accessHintOnCompactionStart();
/**
* This is a maximum buffer size that is used by WinMmapReadableFile in

View File

@ -840,6 +840,7 @@ public class Options extends RocksObject
}
@Override
@Deprecated
public Options setAccessHintOnCompactionStart(final AccessHint accessHint) {
assert(isOwningHandle());
setAccessHintOnCompactionStart(nativeHandle_, accessHint.getValue());
@ -847,6 +848,7 @@ public class Options extends RocksObject
}
@Override
@Deprecated
public AccessHint accessHintOnCompactionStart() {
assert(isOwningHandle());
return AccessHint.getAccessHint(accessHintOnCompactionStart(nativeHandle_));

View File

@ -453,6 +453,7 @@ public class DBOptionsTest {
}
}
@SuppressWarnings("deprecated")
@Test
public void accessHintOnCompactionStart() {
try(final DBOptions opt = new DBOptions()) {

View File

@ -699,6 +699,7 @@ public class OptionsTest {
}
}
@SuppressWarnings("deprecated")
@Test
public void accessHintOnCompactionStart() {
try (final Options opt = new Options()) {

View File

@ -1215,23 +1215,7 @@ Status BlockBasedTable::PrefetchIndexAndFilterBlocks(
return s;
}
void BlockBasedTable::SetupForCompaction() {
switch (rep_->ioptions.access_hint_on_compaction_start) {
case Options::NONE:
break;
case Options::NORMAL:
rep_->file->file()->Hint(FSRandomAccessFile::kNormal);
break;
case Options::SEQUENTIAL:
rep_->file->file()->Hint(FSRandomAccessFile::kSequential);
break;
case Options::WILLNEED:
rep_->file->file()->Hint(FSRandomAccessFile::kWillNeed);
break;
default:
assert(false);
}
}
void BlockBasedTable::SetupForCompaction() {}
std::shared_ptr<const TableProperties> BlockBasedTable::GetTableProperties()
const {

View File

@ -0,0 +1 @@
Mark `Options::access_hint_on_compaction_start` related APIs as deprecated. See #11631 for alternative behavior.