summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsueloverso <sue@mongodb.com>2016-01-20 16:56:35 -0500
committersueloverso <sue@mongodb.com>2016-01-20 16:56:35 -0500
commitfd7a3eb9ad1770235c490ec2f79554d64baf5f2e (patch)
treeae63e670bd64a304a50aad4f6e43bd01994bf7f9
parent6874ec478cfc059bb49febad0697af3ce0a220ec (diff)
parentceb588958b8dbac68b35e5d1419343ac6cae321b (diff)
downloadmongo-fd7a3eb9ad1770235c490ec2f79554d64baf5f2e.tar.gz
Merge pull request #2444 from wiredtiger/WT-2296
WT-2296 Yield instead of sleep if the wrlsn thread is finding work.
-rw-r--r--src/conn/conn_log.c18
-rw-r--r--src/include/extern.h2
-rw-r--r--src/log/log.c4
3 files changed, 17 insertions, 7 deletions
diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c
index 3157f6d6af5..50ad688efac 100644
--- a/src/conn/conn_log.c
+++ b/src/conn/conn_log.c
@@ -511,7 +511,7 @@ typedef struct {
* write_lsn in LSN order after the buffer is written to the log file.
*/
int
-__wt_log_wrlsn(WT_SESSION_IMPL *session)
+__wt_log_wrlsn(WT_SESSION_IMPL *session, int *yield)
{
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
@@ -550,6 +550,8 @@ restart:
* based on the release LSN, and then look for them in order.
*/
if (written_i > 0) {
+ if (yield != NULL)
+ *yield = 0;
WT_INSERTION_SORT(written, written_i,
WT_LOG_WRLSN_ENTRY, WT_WRLSN_ENTRY_CMP_LT);
/*
@@ -660,22 +662,30 @@ __log_wrlsn_server(void *arg)
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
WT_SESSION_IMPL *session;
+ int yield;
session = arg;
conn = S2C(session);
+ yield = 0;
while (F_ISSET(conn, WT_CONN_LOG_SERVER_RUN)) {
/*
* Write out any log record buffers.
*/
- WT_ERR(__wt_log_wrlsn(session));
- WT_ERR(__wt_cond_wait(session, conn->log_wrlsn_cond, 10000));
+ WT_ERR(__wt_log_wrlsn(session, &yield));
+ /*
+ * If __wt_log_wrlsn did work we want to yield instead of sleep.
+ */
+ if (yield++ < WT_THOUSAND)
+ __wt_yield();
+ else
+ WT_ERR(__wt_cond_wait(session, conn->log_wrlsn_cond, 10000));
}
/*
* On close we need to do this one more time because there could
* be straggling log writes that need to be written.
*/
WT_ERR(__wt_log_force_write(session, 1));
- WT_ERR(__wt_log_wrlsn(session));
+ WT_ERR(__wt_log_wrlsn(session, NULL));
if (0) {
err: __wt_err(session, ret, "log wrlsn server error");
}
diff --git a/src/include/extern.h b/src/include/extern.h
index aa5e844b3ba..0a2d1645b2f 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -263,7 +263,7 @@ extern int __wt_connection_init(WT_CONNECTION_IMPL *conn);
extern int __wt_connection_destroy(WT_CONNECTION_IMPL *conn);
extern int __wt_logmgr_reconfig(WT_SESSION_IMPL *session, const char **cfg);
extern int __wt_log_truncate_files( WT_SESSION_IMPL *session, WT_CURSOR *cursor, const char *cfg[]);
-extern int __wt_log_wrlsn(WT_SESSION_IMPL *session);
+extern int __wt_log_wrlsn(WT_SESSION_IMPL *session, int *yield);
extern int __wt_logmgr_create(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_logmgr_open(WT_SESSION_IMPL *session);
extern int __wt_logmgr_destroy(WT_SESSION_IMPL *session);
diff --git a/src/log/log.c b/src/log/log.c
index afae054ec92..82fa0741428 100644
--- a/src/log/log.c
+++ b/src/log/log.c
@@ -47,7 +47,7 @@ __wt_log_flush_lsn(WT_SESSION_IMPL *session, WT_LSN *lsn, bool start)
conn = S2C(session);
log = conn->log;
WT_RET(__wt_log_force_write(session, 1));
- WT_RET(__wt_log_wrlsn(session));
+ WT_RET(__wt_log_wrlsn(session, NULL));
if (start)
*lsn = log->write_start_lsn;
else
@@ -771,7 +771,7 @@ __log_newfile(WT_SESSION_IMPL *session, bool conn_open, bool *created)
WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_SLOT));
while (log->log_close_fh != NULL) {
WT_STAT_FAST_CONN_INCR(session, log_close_yields);
- WT_RET(__wt_log_wrlsn(session));
+ WT_RET(__wt_log_wrlsn(session, NULL));
if (++yield_cnt > 10000)
return (EBUSY);
__wt_yield();