diff options
author | dwight <dwight@10gen.com> | 2011-08-10 06:53:27 -0400 |
---|---|---|
committer | dwight <dwight@10gen.com> | 2011-08-10 06:54:42 -0400 |
commit | fcf1abff4017a9dc5652cdf6b0753d7609dbc096 (patch) | |
tree | d7e1695b6fb36a545ea2553eb6bac82251480396 | |
parent | 6f6ba51e04d8787ebcab9852e01912c6670e5a3b (diff) | |
download | mongo-fcf1abff4017a9dc5652cdf6b0753d7609dbc096.tar.gz |
SERVER-2506 journal faster if a j:1 pending
-rw-r--r-- | db/dur.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/db/dur.cpp b/db/dur.cpp index cc3a985546d..d329fdd16b6 100644 --- a/db/dur.cpp +++ b/db/dur.cpp @@ -690,27 +690,32 @@ namespace mongo { void durThread() { Client::initThread("journal"); - bool same = false; - try { same = onSamePartition(getJournalDir().string(), dbpath); } + bool samePartition = false; + try { samePartition = onSamePartition(getJournalDir().string(), dbpath); } catch(...) { } while( !inShutdown() ) { unsigned ms = cmdLine.journalCommitInterval; if( ms == 0 ) { // use default - ms = same ? 100 : 30; + ms = samePartition ? 100 : 30; } - assert( ms >= 2 ); + + unsigned oneThird = (ms / 3) + 1; // +1 so never zero try { stats.rotate(); - // we do this in a couple blocks, which makes it a tiny bit faster (only a little) on throughput, - // but is likely also less spiky on our cpu usage, which is good: - sleepmillis(ms/2); - commitJob.wi()._deferred.invoke(); - sleepmillis(ms/2); - commitJob.wi()._deferred.invoke(); + // we do this in a couple blocks (the invoke()), which makes it a tiny bit faster (only a little) on throughput, + // but is likely also less spiky on our cpu usage, which is good. + + // commit sooner if one or more getLastError j:true is pending + for( unsigned i = 1; i <= 2; i++ ) { + sleepmillis(oneThird); + if( commitJob._notify.nWaiting() ) + break; + commitJob.wi()._deferred.invoke(); + } go(); } |