avoid extra calls to gettimeofday() when the log is not durable; set group commit to wait for 10msec, not 100...
This commit is contained in:
parent
95e9158847
commit
4ce4491097
1 changed files with 32 additions and 27 deletions
|
@ -197,19 +197,21 @@ static void groupCommit(stasis_log_t* log, lsn_t lsn) {
|
|||
static pthread_mutex_t check_commit = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t tooFewXacts = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
struct timeval now;
|
||||
struct timespec timeout;
|
||||
|
||||
pthread_mutex_lock(&check_commit);
|
||||
if(log->first_unstable_lsn(log,LOG_FORCE_COMMIT) > lsn) {
|
||||
pthread_mutex_unlock(&check_commit);
|
||||
return;
|
||||
}
|
||||
if(log->is_durable(log)) {
|
||||
struct timeval now;
|
||||
struct timespec timeout;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
timeout.tv_sec = now.tv_sec;
|
||||
timeout.tv_nsec = now.tv_usec * 1000;
|
||||
// 0123456789 <- number of zeros on the next three lines...
|
||||
timeout.tv_nsec += 100000000; // wait ten msec.
|
||||
timeout.tv_nsec += 10000000; // wait ten msec.
|
||||
if(timeout.tv_nsec > 1000000000) {
|
||||
timeout.tv_nsec -= 1000000000;
|
||||
timeout.tv_sec++;
|
||||
|
@ -217,7 +219,7 @@ static void groupCommit(stasis_log_t* log, lsn_t lsn) {
|
|||
|
||||
pendingCommits++;
|
||||
int xactcount = TactiveTransactionCount();
|
||||
if((log->is_durable(log) && xactcount > 1 && pendingCommits < xactcount) ||
|
||||
if((xactcount > 1 && pendingCommits < xactcount) ||
|
||||
(xactcount > 20 && pendingCommits < (int)((double)xactcount * 0.95))) {
|
||||
int retcode;
|
||||
while(ETIMEDOUT != (retcode = pthread_cond_timedwait(&tooFewXacts, &check_commit, &timeout))) {
|
||||
|
@ -234,6 +236,9 @@ static void groupCommit(stasis_log_t* log, lsn_t lsn) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pendingCommits++;
|
||||
}
|
||||
if(log->first_unstable_lsn(log,LOG_FORCE_COMMIT) <= lsn) {
|
||||
log->force_tail(log, LOG_FORCE_COMMIT);
|
||||
assert(log->first_unstable_lsn(log,LOG_FORCE_COMMIT) > lsn);
|
||||
|
|
Loading…
Reference in a new issue