Skip to content
Browse files

Disabled notifications to TapConnMap by default

During _normal_ load the server will receive data mutations causing the
system to process events all the time. Grabbing the mutex just to send
a notification will only lead to contention on the mutex.

To avoid the thread to busy-loop we're going to do a 1 sec sleep if
there isn't _any_ work to be performed.

Change-Id: Id47e0b6cc5d6678d6db1b16e0fe00811cacfa28d
Reviewed-on: http://review.couchbase.org/10320
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
  • Loading branch information...
1 parent aa26168 commit 21abdf2428ca3c70ee4a2d58013a62c73f21a74d @trondn trondn committed with chiyoung Oct 24, 2011
Showing with 32 additions and 14 deletions.
  1. +6 −0 configuration.json
  2. +1 −0 ep_testsuite.cc
  3. +19 −12 tapconnmap.cc
  4. +6 −2 tapconnmap.hh
View
6 configuration.json
@@ -264,6 +264,12 @@
"descr": "Number of seconds between a noop is sent on an idle connection",
"type": "size_t"
},
+ "tap_conn_map_notifications": {
+ "default": "false",
+ "descr": "Should TapConnMap use notifications or not",
+ "dynamic": false,
+ "type": "bool"
+ },
"vb0": {
"default": "true",
"type": "bool"
View
1 ep_testsuite.cc
@@ -6346,6 +6346,7 @@ engine_test_t* get_tests(void) {
MEMCACHED_PUBLIC_API
bool setup_suite(struct test_harness *th) {
+ putenv(const_cast<char*>("EP-ENGINE-TESTSUITE=true"));
testHarness = *th;
return true;
}
View
31 tapconnmap.cc
@@ -60,12 +60,16 @@ class TapConnMapValueChangeListener : public ValueChangedListener {
};
TapConnMap::TapConnMap(EventuallyPersistentEngine &theEngine) :
- engine(theEngine), nextTapNoop(0)
+ engine(theEngine), nextTapNoop(0),
+ doNotify(getenv("EP-ENGINE-TESTSUITE") != NULL)
{
Configuration &config = engine.getConfiguration();
tapNoopInterval = config.getTapNoopInterval();
config.addValueChangedListener("tap_noop_interval",
new TapConnMapValueChangeListener(*this));
+ if (config.isTapConnMapNotifications()) {
+ doNotify = true;
+ }
}
void TapConnMap::disconnect(const void *cookie, int tapKeepAlive) {
@@ -89,7 +93,9 @@ void TapConnMap::disconnect(const void *cookie, int tapKeepAlive) {
map.erase(iter);
// Notify the daemon thread so that it may reap them..
- notifySync.notify();
+ if (doNotify) {
+ notifySync.notify();
+ }
}
}
@@ -108,7 +114,7 @@ bool TapConnMap::setEvents(const std::string &name,
shouldNotify = tp->paused; // notify if paused
}
- if (shouldNotify) {
+ if (shouldNotify && doNotify) {
notifySync.notify();
}
@@ -211,7 +217,7 @@ void TapConnMap::addFlushEvent() {
shouldNotify = true;
}
}
- if (shouldNotify) {
+ if (shouldNotify && doNotify) {
notifySync.notify();
}
}
@@ -419,7 +425,7 @@ void TapConnMap::scheduleBackfill(const std::set<uint16_t> &backfillVBuckets) {
shouldNotify = true;
}
}
- if (shouldNotify) {
+ if (shouldNotify && doNotify) {
notifySync.notify();
}
}
@@ -440,7 +446,9 @@ void TapConnMap::resetReplicaChain() {
// replica vbuckets, and then backfills items to the destination.
tp->scheduleBackfill(vblist);
}
- notifySync.notify();
+ if (doNotify) {
+ notifySync.notify();
+ }
}
void TapConnMap::notifyIOThreadMain() {
@@ -491,11 +499,8 @@ void TapConnMap::notifyIOThreadMain() {
}
if (shouldPause) {
- double diff = nextTapNoop - now;
- if (diff > 0) {
- notifySync.wait(diff);
- }
-
+ // We're going to do a full second wait
+ notifySync.wait(1.0);
if (engine.shutdown) {
return;
}
@@ -570,7 +575,9 @@ bool TapConnMap::closeTapConnectionByName(const std::string &name) {
tp->setDisconnect(true);
tp->paused = true;
rv = true;
- notifySync.notify();
+ if (doNotify) {
+ notifySync.notify();
+ }
}
}
return rv;
View
8 tapconnmap.hh
@@ -196,8 +196,10 @@ public:
* Notify anyone who's waiting for tap stuff.
*/
void notify() {
- LockHolder lh(notifySync);
- notifySync.notify();
+ if (doNotify) {
+ LockHolder lh(notifySync);
+ notifySync.notify();
+ }
}
void wait(double howlong) {
@@ -312,6 +314,8 @@ private:
EventuallyPersistentEngine &engine;
size_t tapNoopInterval;
size_t nextTapNoop;
+
+ bool doNotify;
};
#endif /* TAPCONNMAP_HH */

0 comments on commit 21abdf2

Please sign in to comment.
Something went wrong with that request. Please try again.