Skip to content

Commit 21ddcf6

Browse files
committed
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
1 parent fb4a492 commit 21ddcf6

File tree

12 files changed

+28
-114
lines changed

12 files changed

+28
-114
lines changed

HISTORY.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
* 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.
99
* When disableDataSync=true, we no longer sync the MANIFEST file.
1010
* Add identity_as_first_hash property to CuckooTable. SST file needs to be rebuilt to be opened by reader properly.
11+
12+
### Public API changes
1113
* Change target_file_size_base type to uint64_t from int.
14+
* Remove allow_thread_local. This feature was proved to be stable, so we are turning it always-on.
1215

1316
----- Past Releases -----
1417

db/c.cc

+2-7
Original file line numberDiff line numberDiff line change
@@ -1355,8 +1355,8 @@ void rocksdb_options_set_purge_redundant_kvs_while_flush(
13551355
opt->rep.purge_redundant_kvs_while_flush = v;
13561356
}
13571357

1358-
void rocksdb_options_set_allow_os_buffer(
1359-
rocksdb_options_t* opt, unsigned char v) {
1358+
void rocksdb_options_set_allow_os_buffer(rocksdb_options_t* opt,
1359+
unsigned char v) {
13601360
opt->rep.allow_os_buffer = v;
13611361
}
13621362

@@ -1581,11 +1581,6 @@ void rocksdb_options_set_bloom_locality(
15811581
opt->rep.bloom_locality = v;
15821582
}
15831583

1584-
void rocksdb_options_set_allow_thread_local(
1585-
rocksdb_options_t* opt, unsigned char v) {
1586-
opt->rep.allow_thread_local = v;
1587-
}
1588-
15891584
void rocksdb_options_set_inplace_update_support(
15901585
rocksdb_options_t* opt, unsigned char v) {
15911586
opt->rep.inplace_update_support = v;

db/column_family.cc

+5-13
Original file line numberDiff line numberDiff line change
@@ -411,16 +411,10 @@ Compaction* ColumnFamilyData::CompactRange(int input_level, int output_level,
411411
SuperVersion* ColumnFamilyData::GetReferencedSuperVersion(
412412
port::Mutex* db_mutex) {
413413
SuperVersion* sv = nullptr;
414-
if (LIKELY(column_family_set_->db_options_->allow_thread_local)) {
415-
sv = GetThreadLocalSuperVersion(db_mutex);
416-
sv->Ref();
417-
if (!ReturnThreadLocalSuperVersion(sv)) {
418-
sv->Unref();
419-
}
420-
} else {
421-
db_mutex->Lock();
422-
sv = super_version_->Ref();
423-
db_mutex->Unlock();
414+
sv = GetThreadLocalSuperVersion(db_mutex);
415+
sv->Ref();
416+
if (!ReturnThreadLocalSuperVersion(sv)) {
417+
sv->Unref();
424418
}
425419
return sv;
426420
}
@@ -506,9 +500,7 @@ SuperVersion* ColumnFamilyData::InstallSuperVersion(
506500
++super_version_number_;
507501
super_version_->version_number = super_version_number_;
508502
// Reset SuperVersions cached in thread local storage
509-
if (column_family_set_->db_options_->allow_thread_local) {
510-
ResetThreadLocalSuperVersions();
511-
}
503+
ResetThreadLocalSuperVersions();
512504

513505
RecalculateWriteStallConditions();
514506

db/db_impl.cc

+18-28
Original file line numberDiff line numberDiff line change
@@ -401,24 +401,22 @@ DBImpl::~DBImpl() {
401401
mutex_.Lock();
402402
}
403403

404-
if (db_options_.allow_thread_local) {
405-
// Clean up obsolete files due to SuperVersion release.
406-
// (1) Need to delete to obsolete files before closing because RepairDB()
407-
// scans all existing files in the file system and builds manifest file.
408-
// Keeping obsolete files confuses the repair process.
409-
// (2) Need to check if we Open()/Recover() the DB successfully before
410-
// deleting because if VersionSet recover fails (may be due to corrupted
411-
// manifest file), it is not able to identify live files correctly. As a
412-
// result, all "live" files can get deleted by accident. However, corrupted
413-
// manifest is recoverable by RepairDB().
414-
if (opened_successfully_) {
415-
DeletionState deletion_state;
416-
FindObsoleteFiles(deletion_state, true);
417-
// manifest number starting from 2
418-
deletion_state.manifest_file_number = 1;
419-
if (deletion_state.HaveSomethingToDelete()) {
420-
PurgeObsoleteFiles(deletion_state);
421-
}
404+
// Clean up obsolete files due to SuperVersion release.
405+
// (1) Need to delete to obsolete files before closing because RepairDB()
406+
// scans all existing files in the file system and builds manifest file.
407+
// Keeping obsolete files confuses the repair process.
408+
// (2) Need to check if we Open()/Recover() the DB successfully before
409+
// deleting because if VersionSet recover fails (may be due to corrupted
410+
// manifest file), it is not able to identify live files correctly. As a
411+
// result, all "live" files can get deleted by accident. However, corrupted
412+
// manifest is recoverable by RepairDB().
413+
if (opened_successfully_) {
414+
DeletionState deletion_state;
415+
FindObsoleteFiles(deletion_state, true);
416+
// manifest number starting from 2
417+
deletion_state.manifest_file_number = 1;
418+
if (deletion_state.HaveSomethingToDelete()) {
419+
PurgeObsoleteFiles(deletion_state);
422420
}
423421
}
424422

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

43164314
SuperVersion* DBImpl::GetAndRefSuperVersion(ColumnFamilyData* cfd) {
43174315
// TODO(ljin): consider using GetReferencedSuperVersion() directly
4318-
if (LIKELY(db_options_.allow_thread_local)) {
4319-
return cfd->GetThreadLocalSuperVersion(&mutex_);
4320-
} else {
4321-
MutexLock l(&mutex_);
4322-
return cfd->GetSuperVersion()->Ref();
4323-
}
4316+
return cfd->GetThreadLocalSuperVersion(&mutex_);
43244317
}
43254318

43264319
void DBImpl::ReturnAndCleanupSuperVersion(ColumnFamilyData* cfd,
43274320
SuperVersion* sv) {
4328-
bool unref_sv = true;
4329-
if (LIKELY(db_options_.allow_thread_local)) {
4330-
unref_sv = !cfd->ReturnThreadLocalSuperVersion(sv);
4331-
}
4321+
bool unref_sv = !cfd->ReturnThreadLocalSuperVersion(sv);
43324322

43334323
if (unref_sv) {
43344324
// Release SuperVersion

include/rocksdb/c.h

-2
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,6 @@ extern void rocksdb_options_set_min_partial_merge_operands(
537537
rocksdb_options_t*, uint32_t);
538538
extern void rocksdb_options_set_bloom_locality(
539539
rocksdb_options_t*, uint32_t);
540-
extern void rocksdb_options_set_allow_thread_local(
541-
rocksdb_options_t*, unsigned char);
542540
extern void rocksdb_options_set_inplace_update_support(
543541
rocksdb_options_t*, unsigned char);
544542
extern void rocksdb_options_set_inplace_update_num_locks(

include/rocksdb/options.h

-4
Original file line numberDiff line numberDiff line change
@@ -799,10 +799,6 @@ struct DBOptions {
799799
// Default: false
800800
bool use_adaptive_mutex;
801801

802-
// Allow RocksDB to use thread local storage to optimize performance.
803-
// Default: true
804-
bool allow_thread_local;
805-
806802
// Create DBOptions with default values for all fields
807803
DBOptions();
808804
// Create DBOptions from Options

java/org/rocksdb/Options.java

-27
Original file line numberDiff line numberDiff line change
@@ -1070,33 +1070,6 @@ public Options setBytesPerSync(long bytesPerSync) {
10701070
private native void setBytesPerSync(
10711071
long handle, long bytesPerSync);
10721072

1073-
/**
1074-
* Allow RocksDB to use thread local storage to optimize performance.
1075-
* Default: true
1076-
*
1077-
* @return true if thread-local storage is allowed
1078-
*/
1079-
public boolean allowThreadLocal() {
1080-
assert(isInitialized());
1081-
return allowThreadLocal(nativeHandle_);
1082-
}
1083-
private native boolean allowThreadLocal(long handle);
1084-
1085-
/**
1086-
* Allow RocksDB to use thread local storage to optimize performance.
1087-
* Default: true
1088-
*
1089-
* @param allowThreadLocal true if thread-local storage is allowed.
1090-
* @return the reference to the current option.
1091-
*/
1092-
public Options setAllowThreadLocal(boolean allowThreadLocal) {
1093-
assert(isInitialized());
1094-
setAllowThreadLocal(nativeHandle_, allowThreadLocal);
1095-
return this;
1096-
}
1097-
private native void setAllowThreadLocal(
1098-
long handle, boolean allowThreadLocal);
1099-
11001073
/**
11011074
* Set the config for mem-table.
11021075
*

java/org/rocksdb/test/OptionsTest.java

-6
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,6 @@ public static void main(String[] args) {
184184
assert(opt.bytesPerSync() == longValue);
185185
}
186186

187-
{ // AllowThreadLocal test
188-
boolean boolValue = rand.nextBoolean();
189-
opt.setAllowThreadLocal(boolValue);
190-
assert(opt.allowThreadLocal() == boolValue);
191-
}
192-
193187
{ // WriteBufferSize test
194188
long longValue = rand.nextLong();
195189
opt.setWriteBufferSize(longValue);

java/rocksjni/options.cc

-21
Original file line numberDiff line numberDiff line change
@@ -789,27 +789,6 @@ void Java_org_rocksdb_Options_setBytesPerSync(
789789
static_cast<int64_t>(bytes_per_sync);
790790
}
791791

792-
/*
793-
* Class: org_rocksdb_Options
794-
* Method: allowThreadLocal
795-
* Signature: (J)Z
796-
*/
797-
jboolean Java_org_rocksdb_Options_allowThreadLocal(
798-
JNIEnv* env, jobject jobj, jlong jhandle) {
799-
return reinterpret_cast<rocksdb::Options*>(jhandle)->allow_thread_local;
800-
}
801-
802-
/*
803-
* Class: org_rocksdb_Options
804-
* Method: setAllowThreadLocal
805-
* Signature: (JZ)V
806-
*/
807-
void Java_org_rocksdb_Options_setAllowThreadLocal(
808-
JNIEnv* env, jobject jobj, jlong jhandle, jboolean allow_thread_local) {
809-
reinterpret_cast<rocksdb::Options*>(jhandle)->allow_thread_local =
810-
static_cast<bool>(allow_thread_local);
811-
}
812-
813792
/*
814793
* Method: tableFactoryName
815794
* Signature: (J)Ljava/lang/String

util/options.cc

-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ DBOptions::DBOptions()
213213
advise_random_on_open(true),
214214
access_hint_on_compaction_start(NORMAL),
215215
use_adaptive_mutex(false),
216-
allow_thread_local(true),
217216
bytes_per_sync(0) {}
218217

219218
DBOptions::DBOptions(const Options& options)
@@ -256,7 +255,6 @@ DBOptions::DBOptions(const Options& options)
256255
advise_random_on_open(options.advise_random_on_open),
257256
access_hint_on_compaction_start(options.access_hint_on_compaction_start),
258257
use_adaptive_mutex(options.use_adaptive_mutex),
259-
allow_thread_local(options.allow_thread_local),
260258
bytes_per_sync(options.bytes_per_sync) {}
261259

262260
static const char* const access_hints[] = {

util/options_helper.cc

-2
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ bool GetOptionsFromStrings(
301301
new_options->advise_random_on_open = ParseBoolean(o.first, o.second);
302302
} else if (o.first == "use_adaptive_mutex") {
303303
new_options->use_adaptive_mutex = ParseBoolean(o.first, o.second);
304-
} else if (o.first == "allow_thread_local") {
305-
new_options->allow_thread_local = ParseBoolean(o.first, o.second);
306304
} else if (o.first == "bytes_per_sync") {
307305
new_options->bytes_per_sync = ParseUint64(o.second);
308306
} else {

util/options_test.cc

-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ TEST(OptionsTest, GetOptionsFromStringsTest) {
151151
{"stats_dump_period_sec", "46"},
152152
{"advise_random_on_open", "true"},
153153
{"use_adaptive_mutex", "false"},
154-
{"allow_thread_local", "true"},
155154
{"bytes_per_sync", "47"},
156155
};
157156

@@ -239,7 +238,6 @@ TEST(OptionsTest, GetOptionsFromStringsTest) {
239238
ASSERT_EQ(new_opt.stats_dump_period_sec, 46U);
240239
ASSERT_EQ(new_opt.advise_random_on_open, true);
241240
ASSERT_EQ(new_opt.use_adaptive_mutex, false);
242-
ASSERT_EQ(new_opt.allow_thread_local, true);
243241
ASSERT_EQ(new_opt.bytes_per_sync, static_cast<uint64_t>(47));
244242

245243
options_map["write_buffer_size"] = "hello";

0 commit comments

Comments
 (0)