Remove deprecated Options::access_hint_on_compaction_start (#11654)

Summary:
**Context:**
`Options::access_hint_on_compaction_start ` is marked deprecated and now ready to be removed.

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

Test Plan:
Multiple db_stress runs with pre-PR and post-PR binary randomly to ensure forward/backward compatibility on options 36a5686ec0?fbclid=IwAR2IcdAUdTvw9O9V5GkHEYJRGMVR9p7Ei-LMa-9qiXlj3z80DxjkxlGnP1E
`python3 tools/db_crashtest.py --simple blackbox --interval=30`

Reviewed By: cbi42

Differential Revision: D47892459

Pulled By: hx235

fbshipit-source-id: a62f46a0377fe143be7638e218978d5431c15c56
This commit is contained in:
Hui Xiao 2024-02-05 13:35:19 -08:00 committed by Facebook GitHub Bot
parent 3a287796e3
commit 1a885fe730
21 changed files with 7 additions and 318 deletions

29
db/c.cc
View File

@ -3516,35 +3516,6 @@ unsigned char rocksdb_options_get_advise_random_on_open(
return opt->rep.advise_random_on_open;
}
void rocksdb_options_set_access_hint_on_compaction_start(rocksdb_options_t* opt,
int v) {
switch (v) {
case 0:
opt->rep.access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::Options::NONE;
break;
case 1:
opt->rep.access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::Options::NORMAL;
break;
case 2:
opt->rep.access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::Options::SEQUENTIAL;
break;
case 3:
opt->rep.access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::Options::WILLNEED;
break;
default:
assert(0);
}
}
int rocksdb_options_get_access_hint_on_compaction_start(
rocksdb_options_t* opt) {
return opt->rep.access_hint_on_compaction_start;
}
void rocksdb_options_set_use_adaptive_mutex(rocksdb_options_t* opt,
unsigned char v) {
opt->rep.use_adaptive_mutex = v;

View File

@ -2039,8 +2039,6 @@ int main(int argc, char** argv) {
rocksdb_options_set_advise_random_on_open(o, 1);
CheckCondition(1 == rocksdb_options_get_advise_random_on_open(o));
rocksdb_options_set_access_hint_on_compaction_start(o, 3);
CheckCondition(3 == rocksdb_options_get_access_hint_on_compaction_start(o));
rocksdb_options_set_use_adaptive_mutex(o, 1);
CheckCondition(1 == rocksdb_options_get_use_adaptive_mutex(o));
@ -2236,8 +2234,6 @@ int main(int argc, char** argv) {
CheckCondition(18 == rocksdb_options_get_stats_dump_period_sec(copy));
CheckCondition(5 == rocksdb_options_get_stats_persist_period_sec(copy));
CheckCondition(1 == rocksdb_options_get_advise_random_on_open(copy));
CheckCondition(3 ==
rocksdb_options_get_access_hint_on_compaction_start(copy));
CheckCondition(1 == rocksdb_options_get_use_adaptive_mutex(copy));
CheckCondition(19 == rocksdb_options_get_bytes_per_sync(copy));
CheckCondition(20 == rocksdb_options_get_wal_bytes_per_sync(copy));
@ -2520,11 +2516,6 @@ int main(int argc, char** argv) {
CheckCondition(0 == rocksdb_options_get_advise_random_on_open(copy));
CheckCondition(1 == rocksdb_options_get_advise_random_on_open(o));
rocksdb_options_set_access_hint_on_compaction_start(copy, 2);
CheckCondition(2 ==
rocksdb_options_get_access_hint_on_compaction_start(copy));
CheckCondition(3 == rocksdb_options_get_access_hint_on_compaction_start(o));
rocksdb_options_set_use_adaptive_mutex(copy, 0);
CheckCondition(0 == rocksdb_options_get_use_adaptive_mutex(copy));
CheckCondition(1 == rocksdb_options_get_use_adaptive_mutex(o));

View File

@ -1505,10 +1505,6 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_advise_random_on_open(
rocksdb_options_t*, unsigned char);
extern ROCKSDB_LIBRARY_API unsigned char
rocksdb_options_get_advise_random_on_open(rocksdb_options_t*);
extern ROCKSDB_LIBRARY_API void
rocksdb_options_set_access_hint_on_compaction_start(rocksdb_options_t*, int);
extern ROCKSDB_LIBRARY_API int
rocksdb_options_get_access_hint_on_compaction_start(rocksdb_options_t*);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_use_adaptive_mutex(
rocksdb_options_t*, unsigned char);
extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_use_adaptive_mutex(

View File

@ -954,15 +954,6 @@ 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
enum AccessHint { NONE, NORMAL, SEQUENTIAL, WILLNEED };
AccessHint access_hint_on_compaction_start = NORMAL;
// If non-zero, we perform bigger reads when doing compaction. If you're
// running RocksDB on spinning disks, you should set this to at least 2MB.
// That way RocksDB's compaction is doing sequential instead of random reads.

View File

@ -299,9 +299,9 @@ class OptionTypeInfo {
template <typename T>
static OptionTypeInfo Enum(
int offset, const std::unordered_map<std::string, T>* const map,
OptionTypeFlags flags = OptionTypeFlags::kNone) {
OptionTypeInfo info(offset, OptionType::kEnum,
OptionVerificationType::kNormal, flags);
OptionTypeFlags flags = OptionTypeFlags::kNone,
OptionVerificationType verification = OptionVerificationType::kNormal) {
OptionTypeInfo info(offset, OptionType::kEnum, verification, flags);
info.SetParseFunc(
// Uses the map argument to convert the input string into
// its corresponding enum value. If value is found in the map,

View File

@ -115,7 +115,6 @@ set(JAVA_MAIN_CLASSES
src/main/java/org/rocksdb/AbstractTransactionNotifier.java
src/main/java/org/rocksdb/AbstractWalFilter.java
src/main/java/org/rocksdb/AbstractWriteBatch.java
src/main/java/org/rocksdb/AccessHint.java
src/main/java/org/rocksdb/AdvancedColumnFamilyOptionsInterface.java
src/main/java/org/rocksdb/AdvancedMutableColumnFamilyOptionsInterface.java
src/main/java/org/rocksdb/BackgroundErrorReason.java
@ -870,4 +869,4 @@ foreach (CLAZZ ${JAVA_TEST_RUNNING_CLASSES})
COMMAND ${Java_JAVA_EXECUTABLE} ${JVMARGS} -ea -Xcheck:jni -Djava.library.path=${PROJECT_BINARY_DIR}/java -classpath ${JAVA_RUN_TESTCLASSPATH}:${ROCKSDBJNI_CLASSES_TEST_JAR_FILE} org.rocksdb.test.RocksJunitRunner ${CLAZZ}
)
endif()
endforeach(CLAZZ)
endforeach(CLAZZ)

View File

@ -614,9 +614,6 @@ public class DbBenchmark {
(Integer)flags_.get(Flag.universal_compression_size_percent));
// TODO(yhchiang): add RocksDB.openForReadOnly() to enable Flag.readonly
// TODO(yhchiang): enable Flag.merge_operator by switch
options.setAccessHintOnCompactionStart(
(String)flags_.get(Flag.compaction_fadvice));
// available values of fadvice are "NONE", "NORMAL", "SEQUENTIAL", "WILLNEED" for fadvice
*/
}

View File

@ -1554,30 +1554,6 @@ jlong Java_org_rocksdb_Options_dbWriteBufferSize(JNIEnv*, jclass,
return static_cast<jlong>(opt->db_write_buffer_size);
}
/*
* Class: org_rocksdb_Options
* Method: setAccessHintOnCompactionStart
* Signature: (JB)V
*/
void Java_org_rocksdb_Options_setAccessHintOnCompactionStart(
JNIEnv*, jclass, jlong jhandle, jbyte jaccess_hint_value) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::Options*>(jhandle);
opt->access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::AccessHintJni::toCppAccessHint(jaccess_hint_value);
}
/*
* Class: org_rocksdb_Options
* Method: accessHintOnCompactionStart
* Signature: (J)B
*/
jbyte Java_org_rocksdb_Options_accessHintOnCompactionStart(JNIEnv*, jclass,
jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::Options*>(jhandle);
return ROCKSDB_NAMESPACE::AccessHintJni::toJavaAccessHint(
opt->access_hint_on_compaction_start);
}
/*
* Class: org_rocksdb_Options
* Method: setCompactionReadaheadSize
@ -7084,30 +7060,6 @@ jlong Java_org_rocksdb_DBOptions_dbWriteBufferSize(JNIEnv*, jclass,
return static_cast<jlong>(opt->db_write_buffer_size);
}
/*
* Class: org_rocksdb_DBOptions
* Method: setAccessHintOnCompactionStart
* Signature: (JB)V
*/
void Java_org_rocksdb_DBOptions_setAccessHintOnCompactionStart(
JNIEnv*, jclass, jlong jhandle, jbyte jaccess_hint_value) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions*>(jhandle);
opt->access_hint_on_compaction_start =
ROCKSDB_NAMESPACE::AccessHintJni::toCppAccessHint(jaccess_hint_value);
}
/*
* Class: org_rocksdb_DBOptions
* Method: accessHintOnCompactionStart
* Signature: (J)B
*/
jbyte Java_org_rocksdb_DBOptions_accessHintOnCompactionStart(JNIEnv*, jclass,
jlong jhandle) {
auto* opt = reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions*>(jhandle);
return ROCKSDB_NAMESPACE::AccessHintJni::toJavaAccessHint(
opt->access_hint_on_compaction_start);
}
/*
* Class: org_rocksdb_DBOptions
* Method: setCompactionReadaheadSize

View File

@ -4730,48 +4730,6 @@ class CompactionPriorityJni {
}
};
// The portal class for org.rocksdb.AccessHint
class AccessHintJni {
public:
// Returns the equivalent org.rocksdb.AccessHint for the provided
// C++ ROCKSDB_NAMESPACE::DBOptions::AccessHint enum
static jbyte toJavaAccessHint(
const ROCKSDB_NAMESPACE::DBOptions::AccessHint& access_hint) {
switch (access_hint) {
case ROCKSDB_NAMESPACE::DBOptions::AccessHint::NONE:
return 0x0;
case ROCKSDB_NAMESPACE::DBOptions::AccessHint::NORMAL:
return 0x1;
case ROCKSDB_NAMESPACE::DBOptions::AccessHint::SEQUENTIAL:
return 0x2;
case ROCKSDB_NAMESPACE::DBOptions::AccessHint::WILLNEED:
return 0x3;
default:
// undefined/default
return 0x1;
}
}
// Returns the equivalent C++ ROCKSDB_NAMESPACE::DBOptions::AccessHint enum
// for the provided Java org.rocksdb.AccessHint
static ROCKSDB_NAMESPACE::DBOptions::AccessHint toCppAccessHint(
jbyte jaccess_hint) {
switch (jaccess_hint) {
case 0x0:
return ROCKSDB_NAMESPACE::DBOptions::AccessHint::NONE;
case 0x1:
return ROCKSDB_NAMESPACE::DBOptions::AccessHint::NORMAL;
case 0x2:
return ROCKSDB_NAMESPACE::DBOptions::AccessHint::SEQUENTIAL;
case 0x3:
return ROCKSDB_NAMESPACE::DBOptions::AccessHint::WILLNEED;
default:
// undefined/default
return ROCKSDB_NAMESPACE::DBOptions::AccessHint::NORMAL;
}
}
};
// The portal class for org.rocksdb.WALRecoveryMode
class WALRecoveryModeJni {
public:

View File

@ -1,54 +0,0 @@
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
package org.rocksdb;
/**
* File access pattern once a compaction has started
*/
@Deprecated
public enum AccessHint {
NONE((byte)0x0),
NORMAL((byte)0x1),
SEQUENTIAL((byte)0x2),
WILLNEED((byte)0x3);
private final byte value;
AccessHint(final byte value) {
this.value = value;
}
/**
* <p>Returns the byte value of the enumerations value.</p>
*
* @return byte representation
*/
public byte getValue() {
return value;
}
/**
* <p>Get the AccessHint enumeration value by
* passing the byte identifier to this method.</p>
*
* @param byteIdentifier of AccessHint.
*
* @return AccessHint instance.
*
* @throws IllegalArgumentException if the access hint for the byteIdentifier
* cannot be found
*/
public static AccessHint getAccessHint(final byte byteIdentifier) {
for (final AccessHint accessHint : AccessHint.values()) {
if (accessHint.getValue() == byteIdentifier) {
return accessHint;
}
}
throw new IllegalArgumentException(
"Illegal value provided for AccessHint.");
}
}

View File

@ -746,21 +746,6 @@ public class DBOptions extends RocksObject
return dbWriteBufferSize(nativeHandle_);
}
@Override
@Deprecated
public DBOptions setAccessHintOnCompactionStart(final AccessHint accessHint) {
assert(isOwningHandle());
setAccessHintOnCompactionStart(nativeHandle_, accessHint.getValue());
return this;
}
@Override
@Deprecated
public AccessHint accessHintOnCompactionStart() {
assert(isOwningHandle());
return AccessHint.getAccessHint(accessHintOnCompactionStart(nativeHandle_));
}
@Override
public DBOptions setCompactionReadaheadSize(final long compactionReadaheadSize) {
assert(isOwningHandle());
@ -1360,9 +1345,6 @@ public class DBOptions extends RocksObject
private static native void setWriteBufferManager(
final long dbOptionsHandle, final long writeBufferManagerHandle);
private static native long dbWriteBufferSize(final long handle);
private static native void setAccessHintOnCompactionStart(
final long handle, final byte accessHintOnCompactionStart);
private static native byte accessHintOnCompactionStart(final long handle);
private static native void setCompactionReadaheadSize(
final long handle, final long compactionReadaheadSize);
private static native long compactionReadaheadSize(final long handle);

View File

@ -938,28 +938,6 @@ public interface DBOptionsInterface<T extends DBOptionsInterface<T>> {
*/
long dbWriteBufferSize();
/**
* Specify the file access pattern once a compaction is started.
* It will be applied to all input files of a compaction.
*
* Default: {@link AccessHint#NORMAL}
*
* @param accessHint The access hint
*
* @return the reference to the current options.
*/
@Deprecated T setAccessHintOnCompactionStart(final AccessHint accessHint);
/**
* Specify the file access pattern once a compaction is started.
* It will be applied to all input files of a compaction.
*
* Default: {@link AccessHint#NORMAL}
*
* @return The access hint
*/
@Deprecated AccessHint accessHintOnCompactionStart();
/**
* This is a maximum buffer size that is used by WinMmapReadableFile in
* unbuffered disk I/O mode. We need to maintain an aligned buffer for

View File

@ -834,21 +834,6 @@ public class Options extends RocksObject
return dbWriteBufferSize(nativeHandle_);
}
@Override
@Deprecated
public Options setAccessHintOnCompactionStart(final AccessHint accessHint) {
assert(isOwningHandle());
setAccessHintOnCompactionStart(nativeHandle_, accessHint.getValue());
return this;
}
@Override
@Deprecated
public AccessHint accessHintOnCompactionStart() {
assert(isOwningHandle());
return AccessHint.getAccessHint(accessHintOnCompactionStart(nativeHandle_));
}
@Override
public Options setCompactionReadaheadSize(final long compactionReadaheadSize) {
assert(isOwningHandle());
@ -2268,9 +2253,6 @@ public class Options extends RocksObject
private static native void setWriteBufferManager(
final long handle, final long writeBufferManagerHandle);
private static native long dbWriteBufferSize(final long handle);
private static native void setAccessHintOnCompactionStart(
final long handle, final byte accessHintOnCompactionStart);
private static native byte accessHintOnCompactionStart(final long handle);
private static native void setCompactionReadaheadSize(
final long handle, final long compactionReadaheadSize);
private static native long compactionReadaheadSize(final long handle);

View File

@ -453,16 +453,6 @@ public class DBOptionsTest {
}
}
@SuppressWarnings("deprecated")
@Test
public void accessHintOnCompactionStart() {
try(final DBOptions opt = new DBOptions()) {
final AccessHint accessHint = AccessHint.SEQUENTIAL;
opt.setAccessHintOnCompactionStart(accessHint);
assertThat(opt.accessHintOnCompactionStart()).isEqualTo(accessHint);
}
}
@Test
public void compactionReadaheadSize() {
try(final DBOptions opt = new DBOptions()) {

View File

@ -699,16 +699,6 @@ public class OptionsTest {
}
}
@SuppressWarnings("deprecated")
@Test
public void accessHintOnCompactionStart() {
try (final Options opt = new Options()) {
final AccessHint accessHint = AccessHint.SEQUENTIAL;
opt.setAccessHintOnCompactionStart(accessHint);
assertThat(opt.accessHintOnCompactionStart()).isEqualTo(accessHint);
}
}
@Test
public void compactionReadaheadSize() {
try (final Options opt = new Options()) {

View File

@ -35,12 +35,6 @@ static std::unordered_map<std::string, WALRecoveryMode>
{"kSkipAnyCorruptedRecords",
WALRecoveryMode::kSkipAnyCorruptedRecords}};
static std::unordered_map<std::string, DBOptions::AccessHint>
access_hint_string_map = {{"NONE", DBOptions::AccessHint::NONE},
{"NORMAL", DBOptions::AccessHint::NORMAL},
{"SEQUENTIAL", DBOptions::AccessHint::SEQUENTIAL},
{"WILLNEED", DBOptions::AccessHint::WILLNEED}};
static std::unordered_map<std::string, CacheTier> cache_tier_string_map = {
{"kVolatileTier", CacheTier::kVolatileTier},
{"kNonVolatileBlockTier", CacheTier::kNonVolatileBlockTier}};
@ -357,10 +351,8 @@ static std::unordered_map<std::string, OptionTypeInfo>
OptionType::kUInt64T, OptionVerificationType::kNormal,
OptionTypeFlags::kNone}},
{"access_hint_on_compaction_start",
OptionTypeInfo::Enum<DBOptions::AccessHint>(
offsetof(struct ImmutableDBOptions,
access_hint_on_compaction_start),
&access_hint_string_map)},
OptionTypeInfo::Enum<bool>(0, nullptr, OptionTypeFlags::kNone,
OptionVerificationType::kDeprecated)},
{"info_log_level",
OptionTypeInfo::Enum<InfoLogLevel>(
offsetof(struct ImmutableDBOptions, info_log_level),
@ -724,7 +716,6 @@ ImmutableDBOptions::ImmutableDBOptions(const DBOptions& options)
advise_random_on_open(options.advise_random_on_open),
db_write_buffer_size(options.db_write_buffer_size),
write_buffer_manager(options.write_buffer_manager),
access_hint_on_compaction_start(options.access_hint_on_compaction_start),
random_access_max_buffer_size(options.random_access_max_buffer_size),
use_adaptive_mutex(options.use_adaptive_mutex),
listeners(options.listeners),
@ -862,8 +853,6 @@ void ImmutableDBOptions::Dump(Logger* log) const {
db_write_buffer_size);
ROCKS_LOG_HEADER(log, " Options.write_buffer_manager: %p",
write_buffer_manager.get());
ROCKS_LOG_HEADER(log, " Options.access_hint_on_compaction_start: %d",
static_cast<int>(access_hint_on_compaction_start));
ROCKS_LOG_HEADER(
log, " Options.random_access_max_buffer_size: %" ROCKSDB_PRIszt,
random_access_max_buffer_size);

View File

@ -61,7 +61,6 @@ struct ImmutableDBOptions {
bool advise_random_on_open;
size_t db_write_buffer_size;
std::shared_ptr<WriteBufferManager> write_buffer_manager;
DBOptions::AccessHint access_hint_on_compaction_start;
size_t random_access_max_buffer_size;
bool use_adaptive_mutex;
std::vector<std::shared_ptr<EventListener>> listeners;

View File

@ -120,8 +120,6 @@ DBOptions BuildDBOptions(const ImmutableDBOptions& immutable_db_options,
options.advise_random_on_open = immutable_db_options.advise_random_on_open;
options.db_write_buffer_size = immutable_db_options.db_write_buffer_size;
options.write_buffer_manager = immutable_db_options.write_buffer_manager;
options.access_hint_on_compaction_start =
immutable_db_options.access_hint_on_compaction_start;
options.compaction_readahead_size =
mutable_db_options.compaction_readahead_size;
options.random_access_max_buffer_size =

View File

@ -344,7 +344,6 @@ TEST_F(OptionsSettableTest, DBOptionsAllFieldsSettable) {
"enable_write_thread_adaptive_yield=true;"
"write_thread_slow_yield_usec=5;"
"write_thread_max_yield_usec=1000;"
"access_hint_on_compaction_start=NONE;"
"info_log_level=DEBUG_LEVEL;"
"dump_malloc_stats=false;"
"allow_2pc=false;"

View File

@ -1592,11 +1592,6 @@ DEFINE_bool(advise_random_on_open,
ROCKSDB_NAMESPACE::Options().advise_random_on_open,
"Advise random access on table file open");
DEFINE_string(compaction_fadvice, "NORMAL",
"Access pattern advice when a file is compacted");
static auto FLAGS_compaction_fadvice_e =
ROCKSDB_NAMESPACE::Options().access_hint_on_compaction_start;
DEFINE_bool(use_tailing_iterator, false,
"Use tailing iterator to access a series of keys instead of get");
@ -4616,7 +4611,6 @@ class Benchmark {
options.ttl = FLAGS_ttl_seconds;
// fill storage options
options.advise_random_on_open = FLAGS_advise_random_on_open;
options.access_hint_on_compaction_start = FLAGS_compaction_fadvice_e;
options.use_adaptive_mutex = FLAGS_use_adaptive_mutex;
options.bytes_per_sync = FLAGS_bytes_per_sync;
options.wal_bytes_per_sync = FLAGS_wal_bytes_per_sync;
@ -8654,20 +8648,6 @@ int db_bench_tool(int argc, char** argv) {
exit(1);
}
if (!strcasecmp(FLAGS_compaction_fadvice.c_str(), "NONE")) {
FLAGS_compaction_fadvice_e = ROCKSDB_NAMESPACE::Options::NONE;
} else if (!strcasecmp(FLAGS_compaction_fadvice.c_str(), "NORMAL")) {
FLAGS_compaction_fadvice_e = ROCKSDB_NAMESPACE::Options::NORMAL;
} else if (!strcasecmp(FLAGS_compaction_fadvice.c_str(), "SEQUENTIAL")) {
FLAGS_compaction_fadvice_e = ROCKSDB_NAMESPACE::Options::SEQUENTIAL;
} else if (!strcasecmp(FLAGS_compaction_fadvice.c_str(), "WILLNEED")) {
FLAGS_compaction_fadvice_e = ROCKSDB_NAMESPACE::Options::WILLNEED;
} else {
fprintf(stdout, "Unknown compaction fadvice:%s\n",
FLAGS_compaction_fadvice.c_str());
exit(1);
}
FLAGS_value_size_distribution_type_e =
StringToDistributionType(FLAGS_value_size_distribution_type.c_str());

View File

@ -0,0 +1 @@
Removed deprecated option `access_hint_on_compaction_start`