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
oxigraph-main
Hui Xiao 1 year ago committed by Facebook GitHub Bot
parent 87a21d08fe
commit 09882a52d6
  1. 4
      db/db_impl/db_impl_open.cc
  2. 3
      db/db_options_test.cc
  3. 7
      file/prefetch_test.cc
  4. 3
      include/rocksdb/options.h
  5. 1
      java/src/main/java/org/rocksdb/AccessHint.java
  6. 2
      java/src/main/java/org/rocksdb/DBOptions.java
  7. 4
      java/src/main/java/org/rocksdb/DBOptionsInterface.java
  8. 2
      java/src/main/java/org/rocksdb/Options.java
  9. 1
      java/src/test/java/org/rocksdb/DBOptionsTest.java
  10. 1
      java/src/test/java/org/rocksdb/OptionsTest.java
  11. 18
      table/block_based/block_based_table_reader.cc
  12. 1
      unreleased_history/public_api_changes/mark_dep_access_hint_on_compaction_start.md

@ -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) {
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;
}

@ -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++) {

@ -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);
}
buff_prefetch_count = 0;
ASSERT_GT(cur_table_open_prefetch_tail_read.count,

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

@ -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),

@ -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_));

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

@ -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_));

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

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

@ -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 {

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