diff --git a/db/db_impl/db_impl_open.cc b/db/db_impl/db_impl_open.cc index 3d41520c8..e6d97b125 100644 --- a/db/db_impl/db_impl_open.cc +++ b/db/db_impl/db_impl_open.cc @@ -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; } diff --git a/db/db_options_test.cc b/db/db_options_test.cc index d64d0eae5..df6e10850 100644 --- a/db/db_options_test.cc +++ b/db/db_options_test.cc @@ -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++) { diff --git a/file/prefetch_test.cc b/file/prefetch_test.cc index 6e807f581..15b1c6beb 100644 --- a/file/prefetch_test.cc +++ b/file/prefetch_test.cc @@ -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, diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h index 8b176e6ad..7fac24335 100644 --- a/include/rocksdb/options.h +++ b/include/rocksdb/options.h @@ -942,6 +942,9 @@ struct DBOptions { // Default: null std::shared_ptr 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 diff --git a/java/src/main/java/org/rocksdb/AccessHint.java b/java/src/main/java/org/rocksdb/AccessHint.java index 877c4ab39..b7ccadd84 100644 --- a/java/src/main/java/org/rocksdb/AccessHint.java +++ b/java/src/main/java/org/rocksdb/AccessHint.java @@ -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), diff --git a/java/src/main/java/org/rocksdb/DBOptions.java b/java/src/main/java/org/rocksdb/DBOptions.java index 655d900c3..62ad137ee 100644 --- a/java/src/main/java/org/rocksdb/DBOptions.java +++ b/java/src/main/java/org/rocksdb/DBOptions.java @@ -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_)); diff --git a/java/src/main/java/org/rocksdb/DBOptionsInterface.java b/java/src/main/java/org/rocksdb/DBOptionsInterface.java index ef1b86bff..326da98d2 100644 --- a/java/src/main/java/org/rocksdb/DBOptionsInterface.java +++ b/java/src/main/java/org/rocksdb/DBOptionsInterface.java @@ -935,7 +935,7 @@ public interface DBOptionsInterface> { * * @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> { * * @return The access hint */ - AccessHint accessHintOnCompactionStart(); + @Deprecated AccessHint accessHintOnCompactionStart(); /** * This is a maximum buffer size that is used by WinMmapReadableFile in diff --git a/java/src/main/java/org/rocksdb/Options.java b/java/src/main/java/org/rocksdb/Options.java index bfb0e9e48..d00b489ab 100644 --- a/java/src/main/java/org/rocksdb/Options.java +++ b/java/src/main/java/org/rocksdb/Options.java @@ -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_)); diff --git a/java/src/test/java/org/rocksdb/DBOptionsTest.java b/java/src/test/java/org/rocksdb/DBOptionsTest.java index 882015f3e..d79f78db7 100644 --- a/java/src/test/java/org/rocksdb/DBOptionsTest.java +++ b/java/src/test/java/org/rocksdb/DBOptionsTest.java @@ -453,6 +453,7 @@ public class DBOptionsTest { } } + @SuppressWarnings("deprecated") @Test public void accessHintOnCompactionStart() { try(final DBOptions opt = new DBOptions()) { diff --git a/java/src/test/java/org/rocksdb/OptionsTest.java b/java/src/test/java/org/rocksdb/OptionsTest.java index bef25fc81..4b59464b1 100644 --- a/java/src/test/java/org/rocksdb/OptionsTest.java +++ b/java/src/test/java/org/rocksdb/OptionsTest.java @@ -699,6 +699,7 @@ public class OptionsTest { } } + @SuppressWarnings("deprecated") @Test public void accessHintOnCompactionStart() { try (final Options opt = new Options()) { diff --git a/table/block_based/block_based_table_reader.cc b/table/block_based/block_based_table_reader.cc index 1fc477842..129f87888 100644 --- a/table/block_based/block_based_table_reader.cc +++ b/table/block_based/block_based_table_reader.cc @@ -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 BlockBasedTable::GetTableProperties() const { diff --git a/unreleased_history/public_api_changes/mark_dep_access_hint_on_compaction_start.md b/unreleased_history/public_api_changes/mark_dep_access_hint_on_compaction_start.md new file mode 100644 index 000000000..066caaf3c --- /dev/null +++ b/unreleased_history/public_api_changes/mark_dep_access_hint_on_compaction_start.md @@ -0,0 +1 @@ +Mark `Options::access_hint_on_compaction_start` related APIs as deprecated. See #11631 for alternative behavior. \ No newline at end of file