mirror of https://github.com/facebook/rocksdb.git
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:
parent
87a21d08fe
commit
09882a52d6
|
@ -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);
|
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) {
|
||||||
TEST_SYNC_POINT_CALLBACK("SanitizeOptions:direct_io", nullptr);
|
if (result.use_direct_reads) {
|
||||||
|
TEST_SYNC_POINT_CALLBACK("SanitizeOptions:direct_io", nullptr);
|
||||||
|
}
|
||||||
result.compaction_readahead_size = 1024 * 1024 * 2;
|
result.compaction_readahead_size = 1024 * 1024 * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1043,7 +1043,8 @@ TEST_F(DBOptionsTest, CompactionReadaheadSizeChange) {
|
||||||
const std::string kValue(1024, 'v');
|
const std::string kValue(1024, 'v');
|
||||||
Reopen(options);
|
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_OK(dbfull()->SetDBOptions({{"compaction_readahead_size", "256"}}));
|
||||||
ASSERT_EQ(256, dbfull()->GetDBOptions().compaction_readahead_size);
|
ASSERT_EQ(256, dbfull()->GetDBOptions().compaction_readahead_size);
|
||||||
for (int i = 0; i < 1024; i++) {
|
for (int i = 0; i < 1024; i++) {
|
||||||
|
|
|
@ -238,16 +238,9 @@ TEST_P(PrefetchTest, Basic) {
|
||||||
fs->ClearPrefetchCount();
|
fs->ClearPrefetchCount();
|
||||||
} else {
|
} else {
|
||||||
ASSERT_FALSE(fs->IsPrefetchCalled());
|
ASSERT_FALSE(fs->IsPrefetchCalled());
|
||||||
if (use_direct_io) {
|
// To rule out false positive by the SST file tail prefetch during
|
||||||
// To rule out false positive by the SST file tail prefetch during
|
// compaction output verification
|
||||||
// compaction output verification
|
ASSERT_GT(buff_prefetch_count, 1);
|
||||||
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;
|
buff_prefetch_count = 0;
|
||||||
|
|
||||||
ASSERT_GT(cur_table_open_prefetch_tail_read.count,
|
ASSERT_GT(cur_table_open_prefetch_tail_read.count,
|
||||||
|
|
|
@ -942,6 +942,9 @@ struct DBOptions {
|
||||||
// Default: null
|
// Default: null
|
||||||
std::shared_ptr<WriteBufferManager> write_buffer_manager = nullptr;
|
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.
|
// Specify the file access pattern once a compaction is started.
|
||||||
// It will be applied to all input files of a compaction.
|
// It will be applied to all input files of a compaction.
|
||||||
// Default: NORMAL
|
// Default: NORMAL
|
||||||
|
|
|
@ -8,6 +8,7 @@ package org.rocksdb;
|
||||||
/**
|
/**
|
||||||
* File access pattern once a compaction has started
|
* File access pattern once a compaction has started
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public enum AccessHint {
|
public enum AccessHint {
|
||||||
NONE((byte)0x0),
|
NONE((byte)0x0),
|
||||||
NORMAL((byte)0x1),
|
NORMAL((byte)0x1),
|
||||||
|
|
|
@ -752,6 +752,7 @@ public class DBOptions extends RocksObject
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public DBOptions setAccessHintOnCompactionStart(final AccessHint accessHint) {
|
public DBOptions setAccessHintOnCompactionStart(final AccessHint accessHint) {
|
||||||
assert(isOwningHandle());
|
assert(isOwningHandle());
|
||||||
setAccessHintOnCompactionStart(nativeHandle_, accessHint.getValue());
|
setAccessHintOnCompactionStart(nativeHandle_, accessHint.getValue());
|
||||||
|
@ -759,6 +760,7 @@ public class DBOptions extends RocksObject
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public AccessHint accessHintOnCompactionStart() {
|
public AccessHint accessHintOnCompactionStart() {
|
||||||
assert(isOwningHandle());
|
assert(isOwningHandle());
|
||||||
return AccessHint.getAccessHint(accessHintOnCompactionStart(nativeHandle_));
|
return AccessHint.getAccessHint(accessHintOnCompactionStart(nativeHandle_));
|
||||||
|
|
|
@ -935,7 +935,7 @@ public interface DBOptionsInterface<T extends DBOptionsInterface<T>> {
|
||||||
*
|
*
|
||||||
* @return the reference to the current options.
|
* @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.
|
* 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
|
* @return The access hint
|
||||||
*/
|
*/
|
||||||
AccessHint accessHintOnCompactionStart();
|
@Deprecated AccessHint accessHintOnCompactionStart();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a maximum buffer size that is used by WinMmapReadableFile in
|
* This is a maximum buffer size that is used by WinMmapReadableFile in
|
||||||
|
|
|
@ -840,6 +840,7 @@ public class Options extends RocksObject
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public Options setAccessHintOnCompactionStart(final AccessHint accessHint) {
|
public Options setAccessHintOnCompactionStart(final AccessHint accessHint) {
|
||||||
assert(isOwningHandle());
|
assert(isOwningHandle());
|
||||||
setAccessHintOnCompactionStart(nativeHandle_, accessHint.getValue());
|
setAccessHintOnCompactionStart(nativeHandle_, accessHint.getValue());
|
||||||
|
@ -847,6 +848,7 @@ public class Options extends RocksObject
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public AccessHint accessHintOnCompactionStart() {
|
public AccessHint accessHintOnCompactionStart() {
|
||||||
assert(isOwningHandle());
|
assert(isOwningHandle());
|
||||||
return AccessHint.getAccessHint(accessHintOnCompactionStart(nativeHandle_));
|
return AccessHint.getAccessHint(accessHintOnCompactionStart(nativeHandle_));
|
||||||
|
|
|
@ -453,6 +453,7 @@ public class DBOptionsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecated")
|
||||||
@Test
|
@Test
|
||||||
public void accessHintOnCompactionStart() {
|
public void accessHintOnCompactionStart() {
|
||||||
try(final DBOptions opt = new DBOptions()) {
|
try(final DBOptions opt = new DBOptions()) {
|
||||||
|
|
|
@ -699,6 +699,7 @@ public class OptionsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecated")
|
||||||
@Test
|
@Test
|
||||||
public void accessHintOnCompactionStart() {
|
public void accessHintOnCompactionStart() {
|
||||||
try (final Options opt = new Options()) {
|
try (final Options opt = new Options()) {
|
||||||
|
|
|
@ -1215,23 +1215,7 @@ Status BlockBasedTable::PrefetchIndexAndFilterBlocks(
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockBasedTable::SetupForCompaction() {
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<const TableProperties> BlockBasedTable::GetTableProperties()
|
std::shared_ptr<const TableProperties> BlockBasedTable::GetTableProperties()
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Mark `Options::access_hint_on_compaction_start` related APIs as deprecated. See #11631 for alternative behavior.
|
Loading…
Reference in New Issue