summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2015-01-28 15:52:36 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2015-01-28 15:52:36 +1100
commitb45f7e7685f39e93b2df1afc4a1532b52d90a601 (patch)
tree5d436a55df776b3e4cb6ec703b84d0bcb3c9689e
parent1a29bbba37500f02f48eb9f6d62176ca81eb0c63 (diff)
downloadmongo-b45f7e7685f39e93b2df1afc4a1532b52d90a601.tar.gz
Avoid yielding in logging: it causes problems with large numbers of threads.
refs SERVER-16914
-rw-r--r--src/log/log.c13
-rw-r--r--src/log/log_slot.c8
2 files changed, 16 insertions, 5 deletions
diff --git a/src/log/log.c b/src/log/log.c
index a173a829436..5e1256aec07 100644
--- a/src/log/log.c
+++ b/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/log/log_slot.c b/src/log/log_slot.c
index cb959f28bd7..611587aaa8e 100644
--- a/src/log/log_slot.c
+++ b/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);
}