summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gorrod <alexander.gorrod@mongodb.com>2015-01-28 16:11:33 +1100
committerAlex Gorrod <alexander.gorrod@mongodb.com>2015-01-28 16:11:33 +1100
commit443425101c39d006fa8def3b2686406694ffed7c (patch)
tree0cd3d7595e2481301a1986a86f294974aaab467a
parent30b3767e53bcf73cadc5c957954cafad188ec631 (diff)
parentb45f7e7685f39e93b2df1afc4a1532b52d90a601 (diff)
downloadmongo-443425101c39d006fa8def3b2686406694ffed7c.tar.gz
Merge pull request #1610 from wiredtiger/log-yields
Avoid yielding in logging: it causes problems with large numbers of threads
-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);
}