Remove allow_thread_local

Summary: See https://reviews.facebook.net/D19365

Test Plan: compiles

Reviewers: sdong, yhchiang, ljin

Reviewed By: ljin

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D23907
main
Igor Canadi 10 years ago
parent fb4a492cca
commit 21ddcf6e4f
  1. 3
      HISTORY.md
  2. 9
      db/c.cc
  3. 18
      db/column_family.cc
  4. 46
      db/db_impl.cc
  5. 2
      include/rocksdb/c.h
  6. 4
      include/rocksdb/options.h
  7. 27
      java/org/rocksdb/Options.java
  8. 6
      java/org/rocksdb/test/OptionsTest.java
  9. 21
      java/rocksjni/options.cc
  10. 2
      util/options.cc
  11. 2
      util/options_helper.cc
  12. 2
      util/options_test.cc

@ -8,7 +8,10 @@
* We have refactored our system of stalling writes. Any stall-related statistics' meanings are changed. Instead of per-write stall counts, we now count stalls per-epoch, where epochs are periods between flushes and compactions. You'll find more information in our Tuning Perf Guide once we release RocksDB 3.6. * We have refactored our system of stalling writes. Any stall-related statistics' meanings are changed. Instead of per-write stall counts, we now count stalls per-epoch, where epochs are periods between flushes and compactions. You'll find more information in our Tuning Perf Guide once we release RocksDB 3.6.
* When disableDataSync=true, we no longer sync the MANIFEST file. * When disableDataSync=true, we no longer sync the MANIFEST file.
* Add identity_as_first_hash property to CuckooTable. SST file needs to be rebuilt to be opened by reader properly. * Add identity_as_first_hash property to CuckooTable. SST file needs to be rebuilt to be opened by reader properly.
### Public API changes
* Change target_file_size_base type to uint64_t from int. * Change target_file_size_base type to uint64_t from int.
* Remove allow_thread_local. This feature was proved to be stable, so we are turning it always-on.
----- Past Releases ----- ----- Past Releases -----

@ -1355,8 +1355,8 @@ void rocksdb_options_set_purge_redundant_kvs_while_flush(
opt->rep.purge_redundant_kvs_while_flush = v; opt->rep.purge_redundant_kvs_while_flush = v;
} }
void rocksdb_options_set_allow_os_buffer( void rocksdb_options_set_allow_os_buffer(rocksdb_options_t* opt,
rocksdb_options_t* opt, unsigned char v) { unsigned char v) {
opt->rep.allow_os_buffer = v; opt->rep.allow_os_buffer = v;
} }
@ -1581,11 +1581,6 @@ void rocksdb_options_set_bloom_locality(
opt->rep.bloom_locality = v; opt->rep.bloom_locality = v;
} }
void rocksdb_options_set_allow_thread_local(
rocksdb_options_t* opt, unsigned char v) {
opt->rep.allow_thread_local = v;
}
void rocksdb_options_set_inplace_update_support( void rocksdb_options_set_inplace_update_support(
rocksdb_options_t* opt, unsigned char v) { rocksdb_options_t* opt, unsigned char v) {
opt->rep.inplace_update_support = v; opt->rep.inplace_update_support = v;

@ -411,16 +411,10 @@ Compaction* ColumnFamilyData::CompactRange(int input_level, int output_level,
SuperVersion* ColumnFamilyData::GetReferencedSuperVersion( SuperVersion* ColumnFamilyData::GetReferencedSuperVersion(
port::Mutex* db_mutex) { port::Mutex* db_mutex) {
SuperVersion* sv = nullptr; SuperVersion* sv = nullptr;
if (LIKELY(column_family_set_->db_options_->allow_thread_local)) { sv = GetThreadLocalSuperVersion(db_mutex);
sv = GetThreadLocalSuperVersion(db_mutex); sv->Ref();
sv->Ref(); if (!ReturnThreadLocalSuperVersion(sv)) {
if (!ReturnThreadLocalSuperVersion(sv)) { sv->Unref();
sv->Unref();
}
} else {
db_mutex->Lock();
sv = super_version_->Ref();
db_mutex->Unlock();
} }
return sv; return sv;
} }
@ -506,9 +500,7 @@ SuperVersion* ColumnFamilyData::InstallSuperVersion(
++super_version_number_; ++super_version_number_;
super_version_->version_number = super_version_number_; super_version_->version_number = super_version_number_;
// Reset SuperVersions cached in thread local storage // Reset SuperVersions cached in thread local storage
if (column_family_set_->db_options_->allow_thread_local) { ResetThreadLocalSuperVersions();
ResetThreadLocalSuperVersions();
}
RecalculateWriteStallConditions(); RecalculateWriteStallConditions();

@ -401,24 +401,22 @@ DBImpl::~DBImpl() {
mutex_.Lock(); mutex_.Lock();
} }
if (db_options_.allow_thread_local) { // Clean up obsolete files due to SuperVersion release.
// Clean up obsolete files due to SuperVersion release. // (1) Need to delete to obsolete files before closing because RepairDB()
// (1) Need to delete to obsolete files before closing because RepairDB() // scans all existing files in the file system and builds manifest file.
// scans all existing files in the file system and builds manifest file. // Keeping obsolete files confuses the repair process.
// Keeping obsolete files confuses the repair process. // (2) Need to check if we Open()/Recover() the DB successfully before
// (2) Need to check if we Open()/Recover() the DB successfully before // deleting because if VersionSet recover fails (may be due to corrupted
// deleting because if VersionSet recover fails (may be due to corrupted // manifest file), it is not able to identify live files correctly. As a
// manifest file), it is not able to identify live files correctly. As a // result, all "live" files can get deleted by accident. However, corrupted
// result, all "live" files can get deleted by accident. However, corrupted // manifest is recoverable by RepairDB().
// manifest is recoverable by RepairDB(). if (opened_successfully_) {
if (opened_successfully_) { DeletionState deletion_state;
DeletionState deletion_state; FindObsoleteFiles(deletion_state, true);
FindObsoleteFiles(deletion_state, true); // manifest number starting from 2
// manifest number starting from 2 deletion_state.manifest_file_number = 1;
deletion_state.manifest_file_number = 1; if (deletion_state.HaveSomethingToDelete()) {
if (deletion_state.HaveSomethingToDelete()) { PurgeObsoleteFiles(deletion_state);
PurgeObsoleteFiles(deletion_state);
}
} }
} }
@ -4315,20 +4313,12 @@ bool DBImpl::GetIntPropertyInternal(ColumnFamilyHandle* column_family,
SuperVersion* DBImpl::GetAndRefSuperVersion(ColumnFamilyData* cfd) { SuperVersion* DBImpl::GetAndRefSuperVersion(ColumnFamilyData* cfd) {
// TODO(ljin): consider using GetReferencedSuperVersion() directly // TODO(ljin): consider using GetReferencedSuperVersion() directly
if (LIKELY(db_options_.allow_thread_local)) { return cfd->GetThreadLocalSuperVersion(&mutex_);
return cfd->GetThreadLocalSuperVersion(&mutex_);
} else {
MutexLock l(&mutex_);
return cfd->GetSuperVersion()->Ref();
}
} }
void DBImpl::ReturnAndCleanupSuperVersion(ColumnFamilyData* cfd, void DBImpl::ReturnAndCleanupSuperVersion(ColumnFamilyData* cfd,
SuperVersion* sv) { SuperVersion* sv) {
bool unref_sv = true; bool unref_sv = !cfd->ReturnThreadLocalSuperVersion(sv);
if (LIKELY(db_options_.allow_thread_local)) {
unref_sv = !cfd->ReturnThreadLocalSuperVersion(sv);
}
if (unref_sv) { if (unref_sv) {
// Release SuperVersion // Release SuperVersion

@ -537,8 +537,6 @@ extern void rocksdb_options_set_min_partial_merge_operands(
rocksdb_options_t*, uint32_t); rocksdb_options_t*, uint32_t);
extern void rocksdb_options_set_bloom_locality( extern void rocksdb_options_set_bloom_locality(
rocksdb_options_t*, uint32_t); rocksdb_options_t*, uint32_t);
extern void rocksdb_options_set_allow_thread_local(
rocksdb_options_t*, unsigned char);
extern void rocksdb_options_set_inplace_update_support( extern void rocksdb_options_set_inplace_update_support(
rocksdb_options_t*, unsigned char); rocksdb_options_t*, unsigned char);
extern void rocksdb_options_set_inplace_update_num_locks( extern void rocksdb_options_set_inplace_update_num_locks(

@ -799,10 +799,6 @@ struct DBOptions {
// Default: false // Default: false
bool use_adaptive_mutex; bool use_adaptive_mutex;
// Allow RocksDB to use thread local storage to optimize performance.
// Default: true
bool allow_thread_local;
// Create DBOptions with default values for all fields // Create DBOptions with default values for all fields
DBOptions(); DBOptions();
// Create DBOptions from Options // Create DBOptions from Options

@ -1070,33 +1070,6 @@ public class Options extends RocksObject {
private native void setBytesPerSync( private native void setBytesPerSync(
long handle, long bytesPerSync); long handle, long bytesPerSync);
/**
* Allow RocksDB to use thread local storage to optimize performance.
* Default: true
*
* @return true if thread-local storage is allowed
*/
public boolean allowThreadLocal() {
assert(isInitialized());
return allowThreadLocal(nativeHandle_);
}
private native boolean allowThreadLocal(long handle);
/**
* Allow RocksDB to use thread local storage to optimize performance.
* Default: true
*
* @param allowThreadLocal true if thread-local storage is allowed.
* @return the reference to the current option.
*/
public Options setAllowThreadLocal(boolean allowThreadLocal) {
assert(isInitialized());
setAllowThreadLocal(nativeHandle_, allowThreadLocal);
return this;
}
private native void setAllowThreadLocal(
long handle, boolean allowThreadLocal);
/** /**
* Set the config for mem-table. * Set the config for mem-table.
* *

@ -184,12 +184,6 @@ public class OptionsTest {
assert(opt.bytesPerSync() == longValue); assert(opt.bytesPerSync() == longValue);
} }
{ // AllowThreadLocal test
boolean boolValue = rand.nextBoolean();
opt.setAllowThreadLocal(boolValue);
assert(opt.allowThreadLocal() == boolValue);
}
{ // WriteBufferSize test { // WriteBufferSize test
long longValue = rand.nextLong(); long longValue = rand.nextLong();
opt.setWriteBufferSize(longValue); opt.setWriteBufferSize(longValue);

@ -789,27 +789,6 @@ void Java_org_rocksdb_Options_setBytesPerSync(
static_cast<int64_t>(bytes_per_sync); static_cast<int64_t>(bytes_per_sync);
} }
/*
* Class: org_rocksdb_Options
* Method: allowThreadLocal
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_Options_allowThreadLocal(
JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::Options*>(jhandle)->allow_thread_local;
}
/*
* Class: org_rocksdb_Options
* Method: setAllowThreadLocal
* Signature: (JZ)V
*/
void Java_org_rocksdb_Options_setAllowThreadLocal(
JNIEnv* env, jobject jobj, jlong jhandle, jboolean allow_thread_local) {
reinterpret_cast<rocksdb::Options*>(jhandle)->allow_thread_local =
static_cast<bool>(allow_thread_local);
}
/* /*
* Method: tableFactoryName * Method: tableFactoryName
* Signature: (J)Ljava/lang/String * Signature: (J)Ljava/lang/String

@ -213,7 +213,6 @@ DBOptions::DBOptions()
advise_random_on_open(true), advise_random_on_open(true),
access_hint_on_compaction_start(NORMAL), access_hint_on_compaction_start(NORMAL),
use_adaptive_mutex(false), use_adaptive_mutex(false),
allow_thread_local(true),
bytes_per_sync(0) {} bytes_per_sync(0) {}
DBOptions::DBOptions(const Options& options) DBOptions::DBOptions(const Options& options)
@ -256,7 +255,6 @@ DBOptions::DBOptions(const Options& options)
advise_random_on_open(options.advise_random_on_open), advise_random_on_open(options.advise_random_on_open),
access_hint_on_compaction_start(options.access_hint_on_compaction_start), access_hint_on_compaction_start(options.access_hint_on_compaction_start),
use_adaptive_mutex(options.use_adaptive_mutex), use_adaptive_mutex(options.use_adaptive_mutex),
allow_thread_local(options.allow_thread_local),
bytes_per_sync(options.bytes_per_sync) {} bytes_per_sync(options.bytes_per_sync) {}
static const char* const access_hints[] = { static const char* const access_hints[] = {

@ -301,8 +301,6 @@ bool GetOptionsFromStrings(
new_options->advise_random_on_open = ParseBoolean(o.first, o.second); new_options->advise_random_on_open = ParseBoolean(o.first, o.second);
} else if (o.first == "use_adaptive_mutex") { } else if (o.first == "use_adaptive_mutex") {
new_options->use_adaptive_mutex = ParseBoolean(o.first, o.second); new_options->use_adaptive_mutex = ParseBoolean(o.first, o.second);
} else if (o.first == "allow_thread_local") {
new_options->allow_thread_local = ParseBoolean(o.first, o.second);
} else if (o.first == "bytes_per_sync") { } else if (o.first == "bytes_per_sync") {
new_options->bytes_per_sync = ParseUint64(o.second); new_options->bytes_per_sync = ParseUint64(o.second);
} else { } else {

@ -151,7 +151,6 @@ TEST(OptionsTest, GetOptionsFromStringsTest) {
{"stats_dump_period_sec", "46"}, {"stats_dump_period_sec", "46"},
{"advise_random_on_open", "true"}, {"advise_random_on_open", "true"},
{"use_adaptive_mutex", "false"}, {"use_adaptive_mutex", "false"},
{"allow_thread_local", "true"},
{"bytes_per_sync", "47"}, {"bytes_per_sync", "47"},
}; };
@ -239,7 +238,6 @@ TEST(OptionsTest, GetOptionsFromStringsTest) {
ASSERT_EQ(new_opt.stats_dump_period_sec, 46U); ASSERT_EQ(new_opt.stats_dump_period_sec, 46U);
ASSERT_EQ(new_opt.advise_random_on_open, true); ASSERT_EQ(new_opt.advise_random_on_open, true);
ASSERT_EQ(new_opt.use_adaptive_mutex, false); ASSERT_EQ(new_opt.use_adaptive_mutex, false);
ASSERT_EQ(new_opt.allow_thread_local, true);
ASSERT_EQ(new_opt.bytes_per_sync, static_cast<uint64_t>(47)); ASSERT_EQ(new_opt.bytes_per_sync, static_cast<uint64_t>(47));
options_map["write_buffer_size"] = "hello"; options_map["write_buffer_size"] = "hello";

Loading…
Cancel
Save