summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Pasette <dan@10gen.com>2015-01-28 03:30:51 -0500
committerDan Pasette <dan@mongodb.com>2015-01-28 03:33:29 -0500
commit39325518eeef09a7ac938d63f79b718a49a69535 (patch)
tree2755f3eac4bb3505dbc9ea0a9d9d03ad763a6222
parent81cb23e84653d66158bca6052e21cdae6eec64f4 (diff)
downloadmongo-39325518eeef09a7ac938d63f79b718a49a69535.tar.gz
Import wiredtiger-wiredtiger-mongodb-2.8-rc6-53-gd38a68b.tar.gz from wiredtiger branch mongodb-2.8
(cherry picked from commit 746d9b99a8dc0301c1593bd4dc62fc8433435c7e)
-rw-r--r--src/third_party/wiredtiger/src/include/cache.i1
-rw-r--r--src/third_party/wiredtiger/src/log/log.c13
-rw-r--r--src/third_party/wiredtiger/src/log/log_slot.c8
-rw-r--r--src/third_party/wiredtiger/src/os_posix/os_mtx_rw.c18
4 files changed, 32 insertions, 8 deletions
diff --git a/src/third_party/wiredtiger/src/include/cache.i b/src/third_party/wiredtiger/src/include/cache.i
index 0295451ef11..b1ace5e6a80 100644
--- a/src/third_party/wiredtiger/src/include/cache.i
+++ b/src/third_party/wiredtiger/src/include/cache.i
@@ -175,4 +175,3 @@ __wt_cache_full_check(WT_SESSION_IMPL *session)
return (__wt_cache_wait(session, full));
}
-
diff --git a/src/third_party/wiredtiger/src/log/log.c b/src/third_party/wiredtiger/src/log/log.c
index a173a829436..5e1256aec07 100644
--- a/src/third_party/wiredtiger/src/log/log.c
+++ b/src/third_party/wiredtiger/src/log/log.c
@@ -861,12 +861,12 @@ __log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot)
WT_LOG *log;
WT_LSN sync_lsn;
size_t write_size;
- int locked;
+ int locked, yield_count;
WT_DECL_SPINLOCK_ID(id); /* Must appear last */
conn = S2C(session);
log = conn->log;
- locked = 0;
+ locked = yield_count = 0;
/* Write the buffered records */
if (F_ISSET(slot, SLOT_BUFFERED)) {
@@ -880,8 +880,13 @@ __log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot)
* Wait for earlier groups to finish, otherwise there could be holes
* in the log file.
*/
- while (LOG_CMP(&log->write_lsn, &slot->slot_release_lsn) != 0)
- __wt_yield();
+ while (LOG_CMP(&log->write_lsn, &slot->slot_release_lsn) != 0) {
+ if (++yield_count < 100)
+ __wt_yield();
+ else
+ WT_ERR(__wt_cond_wait(
+ session, log->log_write_cond, 2000));
+ }
log->write_lsn = slot->slot_end_lsn;
WT_ERR(__wt_cond_signal(session, log->log_write_cond));
diff --git a/src/third_party/wiredtiger/src/log/log_slot.c b/src/third_party/wiredtiger/src/log/log_slot.c
index cb959f28bd7..611587aaa8e 100644
--- a/src/third_party/wiredtiger/src/log/log_slot.c
+++ b/src/third_party/wiredtiger/src/log/log_slot.c
@@ -260,10 +260,16 @@ __wt_log_slot_notify(WT_SESSION_IMPL *session, WT_LOGSLOT *slot)
int
__wt_log_slot_wait(WT_SESSION_IMPL *session, WT_LOGSLOT *slot)
{
+ int yield_count;
+
+ yield_count = 0;
WT_UNUSED(session);
while (slot->slot_state > WT_LOG_SLOT_DONE)
- __wt_yield();
+ if (++yield_count < 100)
+ __wt_yield();
+ else
+ __wt_sleep(0, 2000);
return (0);
}
diff --git a/src/third_party/wiredtiger/src/os_posix/os_mtx_rw.c b/src/third_party/wiredtiger/src/os_posix/os_mtx_rw.c
index 4cda976bea8..b266d652671 100644
--- a/src/third_party/wiredtiger/src/os_posix/os_mtx_rw.c
+++ b/src/third_party/wiredtiger/src/os_posix/os_mtx_rw.c
@@ -95,6 +95,7 @@ __wt_readlock(WT_SESSION_IMPL *session, WT_RWLOCK *rwlock)
wt_rwlock_t *l;
uint64_t me;
uint16_t val;
+ int pause_cnt;
WT_RET(__wt_verbose(
session, WT_VERB_MUTEX, "rwlock: readlock %s", rwlock->name));
@@ -103,8 +104,21 @@ __wt_readlock(WT_SESSION_IMPL *session, WT_RWLOCK *rwlock)
l = &rwlock->rwlock;
me = WT_ATOMIC_FETCH_ADD8(l->u, (uint64_t)1 << 32);
val = (uint16_t)(me >> 32);
- while (val != l->s.readers)
- WT_PAUSE();
+ for (pause_cnt = 0; val != l->s.readers;) {
+ /*
+ * We failed to get the lock; pause before retrying and if we've
+ * paused enough, sleep so we don't burn CPU to no purpose. This
+ * situation happens if there are more threads than cores in the
+ * system and we're thrashing on shared resources. Regardless,
+ * don't sleep long, all we need is to schedule the other reader
+ * threads to complete a few more instructions and increment the
+ * reader count.
+ */
+ if (++pause_cnt < 1000)
+ WT_PAUSE();
+ else
+ __wt_sleep(0, 10);
+ }
++l->s.readers;