Skip to content

Commit

Permalink
Remove allow_thread_local
Browse files Browse the repository at this point in the history
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
  • Loading branch information
igorcanadi committed Sep 24, 2014
1 parent fb4a492 commit 21ddcf6
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 114 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* 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.

### Public API changes
* 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 -----

Expand Down
9 changes: 2 additions & 7 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1355,8 +1355,8 @@ void rocksdb_options_set_purge_redundant_kvs_while_flush(
opt->rep.purge_redundant_kvs_while_flush = v;
}

void rocksdb_options_set_allow_os_buffer(
rocksdb_options_t* opt, unsigned char v) {
void rocksdb_options_set_allow_os_buffer(rocksdb_options_t* opt,
unsigned char v) {
opt->rep.allow_os_buffer = v;
}

Expand Down Expand Up @@ -1581,11 +1581,6 @@ void rocksdb_options_set_bloom_locality(
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(
rocksdb_options_t* opt, unsigned char v) {
opt->rep.inplace_update_support = v;
Expand Down
18 changes: 5 additions & 13 deletions db/column_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,10 @@ Compaction* ColumnFamilyData::CompactRange(int input_level, int output_level,
SuperVersion* ColumnFamilyData::GetReferencedSuperVersion(
port::Mutex* db_mutex) {
SuperVersion* sv = nullptr;
if (LIKELY(column_family_set_->db_options_->allow_thread_local)) {
sv = GetThreadLocalSuperVersion(db_mutex);
sv->Ref();
if (!ReturnThreadLocalSuperVersion(sv)) {
sv->Unref();
}
} else {
db_mutex->Lock();
sv = super_version_->Ref();
db_mutex->Unlock();
sv = GetThreadLocalSuperVersion(db_mutex);
sv->Ref();
if (!ReturnThreadLocalSuperVersion(sv)) {
sv->Unref();
}
return sv;
}
Expand Down Expand Up @@ -506,9 +500,7 @@ SuperVersion* ColumnFamilyData::InstallSuperVersion(
++super_version_number_;
super_version_->version_number = super_version_number_;
// Reset SuperVersions cached in thread local storage
if (column_family_set_->db_options_->allow_thread_local) {
ResetThreadLocalSuperVersions();
}
ResetThreadLocalSuperVersions();

RecalculateWriteStallConditions();

Expand Down
46 changes: 18 additions & 28 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,24 +401,22 @@ DBImpl::~DBImpl() {
mutex_.Lock();
}

if (db_options_.allow_thread_local) {
// Clean up obsolete files due to SuperVersion release.
// (1) Need to delete to obsolete files before closing because RepairDB()
// scans all existing files in the file system and builds manifest file.
// Keeping obsolete files confuses the repair process.
// (2) Need to check if we Open()/Recover() the DB successfully before
// deleting because if VersionSet recover fails (may be due to corrupted
// manifest file), it is not able to identify live files correctly. As a
// result, all "live" files can get deleted by accident. However, corrupted
// manifest is recoverable by RepairDB().
if (opened_successfully_) {
DeletionState deletion_state;
FindObsoleteFiles(deletion_state, true);
// manifest number starting from 2
deletion_state.manifest_file_number = 1;
if (deletion_state.HaveSomethingToDelete()) {
PurgeObsoleteFiles(deletion_state);
}
// Clean up obsolete files due to SuperVersion release.
// (1) Need to delete to obsolete files before closing because RepairDB()
// scans all existing files in the file system and builds manifest file.
// Keeping obsolete files confuses the repair process.
// (2) Need to check if we Open()/Recover() the DB successfully before
// deleting because if VersionSet recover fails (may be due to corrupted
// manifest file), it is not able to identify live files correctly. As a
// result, all "live" files can get deleted by accident. However, corrupted
// manifest is recoverable by RepairDB().
if (opened_successfully_) {
DeletionState deletion_state;
FindObsoleteFiles(deletion_state, true);
// manifest number starting from 2
deletion_state.manifest_file_number = 1;
if (deletion_state.HaveSomethingToDelete()) {
PurgeObsoleteFiles(deletion_state);
}
}

Expand Down Expand Up @@ -4315,20 +4313,12 @@ bool DBImpl::GetIntPropertyInternal(ColumnFamilyHandle* column_family,

SuperVersion* DBImpl::GetAndRefSuperVersion(ColumnFamilyData* cfd) {
// TODO(ljin): consider using GetReferencedSuperVersion() directly
if (LIKELY(db_options_.allow_thread_local)) {
return cfd->GetThreadLocalSuperVersion(&mutex_);
} else {
MutexLock l(&mutex_);
return cfd->GetSuperVersion()->Ref();
}
return cfd->GetThreadLocalSuperVersion(&mutex_);
}

void DBImpl::ReturnAndCleanupSuperVersion(ColumnFamilyData* cfd,
SuperVersion* sv) {
bool unref_sv = true;
if (LIKELY(db_options_.allow_thread_local)) {
unref_sv = !cfd->ReturnThreadLocalSuperVersion(sv);
}
bool unref_sv = !cfd->ReturnThreadLocalSuperVersion(sv);

if (unref_sv) {
// Release SuperVersion
Expand Down
2 changes: 0 additions & 2 deletions include/rocksdb/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,6 @@ extern void rocksdb_options_set_min_partial_merge_operands(
rocksdb_options_t*, uint32_t);
extern void rocksdb_options_set_bloom_locality(
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(
rocksdb_options_t*, unsigned char);
extern void rocksdb_options_set_inplace_update_num_locks(
Expand Down
4 changes: 0 additions & 4 deletions include/rocksdb/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,10 +799,6 @@ struct DBOptions {
// Default: false
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
DBOptions();
// Create DBOptions from Options
Expand Down
27 changes: 0 additions & 27 deletions java/org/rocksdb/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -1070,33 +1070,6 @@ public Options setBytesPerSync(long bytesPerSync) {
private native void setBytesPerSync(
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.
*
Expand Down
6 changes: 0 additions & 6 deletions java/org/rocksdb/test/OptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ public static void main(String[] args) {
assert(opt.bytesPerSync() == longValue);
}

{ // AllowThreadLocal test
boolean boolValue = rand.nextBoolean();
opt.setAllowThreadLocal(boolValue);
assert(opt.allowThreadLocal() == boolValue);
}

{ // WriteBufferSize test
long longValue = rand.nextLong();
opt.setWriteBufferSize(longValue);
Expand Down
21 changes: 0 additions & 21 deletions java/rocksjni/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -789,27 +789,6 @@ void Java_org_rocksdb_Options_setBytesPerSync(
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
* Signature: (J)Ljava/lang/String
Expand Down
2 changes: 0 additions & 2 deletions util/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ DBOptions::DBOptions()
advise_random_on_open(true),
access_hint_on_compaction_start(NORMAL),
use_adaptive_mutex(false),
allow_thread_local(true),
bytes_per_sync(0) {}

DBOptions::DBOptions(const Options& options)
Expand Down Expand Up @@ -256,7 +255,6 @@ DBOptions::DBOptions(const Options& options)
advise_random_on_open(options.advise_random_on_open),
access_hint_on_compaction_start(options.access_hint_on_compaction_start),
use_adaptive_mutex(options.use_adaptive_mutex),
allow_thread_local(options.allow_thread_local),
bytes_per_sync(options.bytes_per_sync) {}

static const char* const access_hints[] = {
Expand Down
2 changes: 0 additions & 2 deletions util/options_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,6 @@ bool GetOptionsFromStrings(
new_options->advise_random_on_open = ParseBoolean(o.first, o.second);
} else if (o.first == "use_adaptive_mutex") {
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") {
new_options->bytes_per_sync = ParseUint64(o.second);
} else {
Expand Down
2 changes: 0 additions & 2 deletions util/options_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ TEST(OptionsTest, GetOptionsFromStringsTest) {
{"stats_dump_period_sec", "46"},
{"advise_random_on_open", "true"},
{"use_adaptive_mutex", "false"},
{"allow_thread_local", "true"},
{"bytes_per_sync", "47"},
};

Expand Down Expand Up @@ -239,7 +238,6 @@ TEST(OptionsTest, GetOptionsFromStringsTest) {
ASSERT_EQ(new_opt.stats_dump_period_sec, 46U);
ASSERT_EQ(new_opt.advise_random_on_open, true);
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));

options_map["write_buffer_size"] = "hello";
Expand Down

0 comments on commit 21ddcf6

Please sign in to comment.