Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move throttle and reduce mutex_ lock calls by one. change factor in F…

…inalize() back to 8, was 2 recently (2i_slf_stressmix test)
  • Loading branch information...
commit 0eaa716742235ba5eeaaef7ea9942e0a94d48ce8 1 parent 9a8d9a0
MatthewVon authored
Showing with 23 additions and 19 deletions.
  1. +22 −18 db/db_impl.cc
  2. +1 −1  db/version_set.cc
View
40 db/db_impl.cc
@@ -1469,39 +1469,27 @@ Status DBImpl::Delete(const WriteOptions& options, const Slice& key) {
}
Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
- int throttle;
-
- // protect use of versions_ ... apply lock
- mutex_.Lock();
- throttle=versions_->WriteThrottleUsec(bg_compaction_scheduled_);
- mutex_.Unlock();
- if (0!=throttle)
- {
- /// slowing each call down sequentially
- MutexLock l(&throttle_mutex_);
-
- // throttle is per key write, how many in batch?
- // (batch multiplier killed AAE, removed)
- env_->SleepForMicroseconds(throttle /* * WriteBatchInternal::Count(my_batch)*/);
- gPerfCounters->Add(ePerfDebug0, throttle);
- } // if
+ Status status;
+ int throttle(0);
Writer w(&mutex_);
w.batch = my_batch;
w.sync = options.sync;
w.done = false;
+ { // place mutex_ within a block
+ // not changing tabs to ease compare to Google sources
MutexLock l(&mutex_);
writers_.push_back(&w);
while (!w.done && &w != writers_.front()) {
w.cv.Wait();
}
if (w.done) {
- return w.status;
+ return w.status; // skips throttle ... maintenance unfriendly coding, bastards
}
// May temporarily unlock and wait.
- Status status = MakeRoomForWrite(my_batch == NULL);
+ status = MakeRoomForWrite(my_batch == NULL);
uint64_t last_sequence = versions_->LastSequence();
Writer* last_writer = &w;
if (status.ok() && my_batch != NULL) { // NULL batch is for compactions
@@ -1547,6 +1535,22 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
gPerfCounters->Inc(ePerfApiWrite);
+ // protect use of versions_ ... still within scope of mutex_ lock
+ throttle=versions_->WriteThrottleUsec(bg_compaction_scheduled_);
+ } // release MutexLock l(&mutex_)
+
+ // throttle on exit to reduce possible reordering
+ if (0!=throttle)
+ {
+ /// slowing each call down sequentially
+ MutexLock l(&throttle_mutex_);
+
+ // throttle is per key write, how many in batch?
+ // (batch multiplier killed AAE, removed)
+ env_->SleepForMicroseconds(throttle /* * WriteBatchInternal::Count(my_batch)*/);
+ gPerfCounters->Add(ePerfDebug0, throttle);
+ } // if
+
return status;
}
View
2  db/version_set.cc
@@ -1090,7 +1090,7 @@ void VersionSet::Finalize(Version* v) {
count=(v->files_[level].size() - config::kL0_SlowdownWritesTrigger);
for (loop=0, value=4; loop<count; ++loop)
- value*=2;
+ value*=8;
penalty+=value;
} // else
Please sign in to comment.
Something went wrong with that request. Please try again.