Author: kpvdr
Date: 2010-07-02 09:55:36 -0400 (Fri, 02 Jul 2010)
New Revision: 4067
Modified:
store/trunk/cpp/lib/JournalImpl.cpp
store/trunk/cpp/lib/MessageStoreImpl.cpp
store/trunk/cpp/lib/TxnCtxt.cpp
store/trunk/cpp/lib/jrnl/jcntl.cpp
Log:
Reduced store sleep times when waiting for synchronous libaio operations; this improves
throughput at the expense of efficiency, but I think the change is worth it judging by
initial performance checks.
Modified: store/trunk/cpp/lib/JournalImpl.cpp
===================================================================
--- store/trunk/cpp/lib/JournalImpl.cpp 2010-07-02 13:39:56 UTC (rev 4066)
+++ store/trunk/cpp/lib/JournalImpl.cpp 2010-07-02 13:55:36 UTC (rev 4067)
@@ -237,8 +237,8 @@
_emap.size(), _tmap.size(), _tmap.enq_cnt(), _tmap.deq_cnt()),
qpid::management::ManagementAgent::SEV_NOTE);
}
-#define MAX_AIO_SLEEPS 1000 // 10 sec
-#define AIO_SLEEP_TIME 10000 // 10 ms
+#define MAX_AIO_SLEEPS 1000000 // tot: ~10 sec
+#define AIO_SLEEP_TIME_US 10 // 0.01 ms
// Return true if content is recovered from store; false if content is external and must
be recovered from an external store.
// Throw exception for all errors.
bool
@@ -297,7 +297,7 @@
case mrg::journal::RHM_IORES_PAGE_AIOWAIT:
if (++aio_sleep_cnt <= MAX_AIO_SLEEPS) {
get_wr_events();
- usleep(AIO_SLEEP_TIME);
+ usleep(AIO_SLEEP_TIME_US);
} else {
std::stringstream ss;
ss << "read_data_record() returned " <<
mrg::journal::iores_str(res);
Modified: store/trunk/cpp/lib/MessageStoreImpl.cpp
===================================================================
--- store/trunk/cpp/lib/MessageStoreImpl.cpp 2010-07-02 13:39:56 UTC (rev 4066)
+++ store/trunk/cpp/lib/MessageStoreImpl.cpp 2010-07-02 13:55:36 UTC (rev 4067)
@@ -32,8 +32,8 @@
#include "StoreException.h"
#include <dirent.h>
-#define MAX_AIO_SLEEPS 1000 // ~1 second
-#define AIO_SLEEP_TIME 1000 // 1 Millisecond
+#define MAX_AIO_SLEEPS 100000 // tot: ~1 sec
+#define AIO_SLEEP_TIME_US 10 // 0.01 ms
using namespace mrg::msgstore;
using namespace qpid::broker;
@@ -1003,7 +1003,7 @@
case mrg::journal::RHM_IORES_PAGE_AIOWAIT:
if (++aio_sleep_cnt > MAX_AIO_SLEEPS)
THROW_STORE_EXCEPTION("Timeout waiting for AIO in
MessageStoreImpl::recoverMessages()");
- ::usleep(AIO_SLEEP_TIME);
+ ::usleep(AIO_SLEEP_TIME_US);
break;
case mrg::journal::RHM_IORES_EMPTY:
read = false;
@@ -1113,7 +1113,7 @@
case mrg::journal::RHM_IORES_PAGE_AIOWAIT:
if (++aio_sleep_cnt > MAX_AIO_SLEEPS)
THROW_STORE_EXCEPTION("Timeout waiting for AIO in
MessageStoreImpl::recoverTplStore()");
- ::usleep(AIO_SLEEP_TIME);
+ ::usleep(AIO_SLEEP_TIME_US);
break;
case mrg::journal::RHM_IORES_EMPTY:
done = true;
Modified: store/trunk/cpp/lib/TxnCtxt.cpp
===================================================================
--- store/trunk/cpp/lib/TxnCtxt.cpp 2010-07-02 13:39:56 UTC (rev 4066)
+++ store/trunk/cpp/lib/TxnCtxt.cpp 2010-07-02 13:55:36 UTC (rev 4067)
@@ -76,8 +76,8 @@
TxnCtxt::~TxnCtxt() { if(txn) abort(); }
-#define MAX_SYNC_SLEEPS 5000 // ~1 second
-#define SYNC_SLEEP_TIME 200 // 0.2 ms
+#define MAX_SYNC_SLEEPS 100000 // tot: ~1 sec
+#define SYNC_SLEEP_TIME_US 10 // 0.01 ms
void TxnCtxt::sync() {
bool allWritten = false;
@@ -86,7 +86,7 @@
while (loggedtx && !allWritten) {
if (sleep_cnt > MAX_SYNC_SLEEPS)
THROW_STORE_EXCEPTION(std::string("Error: timeout waiting for
TxnCtxt::sync()"));
if (!firstloop) {
- ::usleep(SYNC_SLEEP_TIME);
+ ::usleep(SYNC_SLEEP_TIME_US);
sleep_cnt++;
} // move this into the get events call aiolib..
allWritten = true;
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2010-07-02 13:39:56 UTC (rev 4066)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2010-07-02 13:55:36 UTC (rev 4067)
@@ -264,8 +264,8 @@
} */
// These two combined make a wait time of approx. 2 sec.
-#define MAX_RCINVALID_CNT 400
-#define RCINVALID_SLEEP_TIME_MS 5
+#define MAX_RCINVALID_CNT 20000 // tot: ~ 2 sec
+#define RCINVALID_SLEEP_TIME_US 100 // 0.1 ms
iores
jcntl::read_data_record(void** const datapp, std::size_t& dsize, void** const xidpp,
std::size_t& xidsize,
bool& transient, bool& external, data_tok* const dtokp, bool
ignore_pending_txns)
@@ -283,7 +283,7 @@
if (sres != RHM_IORES_SUCCESS)
return sres;
if (cnt > 0)
- ::usleep(RCINVALID_SLEEP_TIME_MS * 1000);
+ ::usleep(RCINVALID_SLEEP_TIME_US);
}
cnt++;
}
@@ -429,8 +429,8 @@
_rmgr.invalidate();
}
-#define AIO_CMPL_SLEEP 200 // 0.2 ms
-#define MAX_AIO_CMPL_SLEEPS 50000 // Total: 10 sec
+#define MAX_AIO_CMPL_SLEEPS 1000000 // tot: ~10 sec
+#define AIO_CMPL_SLEEP_US 10 // 0.01 ms
void
jcntl::fhdr_wr_sync(const u_int16_t lid)
@@ -442,7 +442,7 @@
{
if (++cnt > MAX_AIO_CMPL_SLEEPS)
throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl",
"fhdr_wr_sync");
- ::usleep(AIO_CMPL_SLEEP);
+ ::usleep(AIO_CMPL_SLEEP_US);
get_wr_events();
}
}
@@ -502,7 +502,7 @@
get_wr_events();
if (cnt++ > MAX_AIO_CMPL_SLEEPS)
throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl",
"aio_cmpl_wait");
- ::usleep(AIO_CMPL_SLEEP);
+ ::usleep(AIO_CMPL_SLEEP_US);
}
}
@@ -525,7 +525,7 @@
this->log(LOG_CRITICAL, oss.str());
throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl",
"handle_aio_wait");
}
- ::usleep(AIO_CMPL_SLEEP);
+ ::usleep(AIO_CMPL_SLEEP_US);
}
return true;
}
@@ -542,7 +542,7 @@
this->log(LOG_CRITICAL, oss.str());
throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl",
"handle_aio_wait");
}
- ::usleep(AIO_CMPL_SLEEP);
+ ::usleep(AIO_CMPL_SLEEP_US);
}
_wrfc.wr_reset();
resout = RHM_IORES_SUCCESS;