don't log right before saving state unless requested

only the journal replay autotest really needs it. in other cases it's
just wasting time and ssd life.
This commit is contained in:
Oswald Buddenhagen 2021-12-11 15:43:21 +01:00
parent d74af51fa1
commit 698f9ff173
5 changed files with 22 additions and 13 deletions

View File

@ -115,6 +115,7 @@ BIT_ENUM(
ZERODELAY,
KEEPJOURNAL,
FORCEJOURNAL,
FORCEASYNC(2),
)

View File

@ -438,6 +438,9 @@ main( int argc, char **argv )
case 'j':
DFlags |= KEEPJOURNAL;
break;
case 'J':
DFlags |= FORCEJOURNAL;
break;
case 's':
JLimit = strtol( ochar, &ochar, 10 );
break;

View File

@ -765,7 +765,7 @@ sub test_impl($$$$)
mkchan($sx);
my ($xc, $ret) = runsync($async, "-Tj", "1-initial.log");
my ($xc, $ret) = runsync($async, "-Tj -TJ", "1-initial.log");
my $rtx = readchan($$sx{state}) if (!$xc);
if ($xc || cmpchan($rtx, $tx)) {
print "Input:\n";

View File

@ -1735,7 +1735,7 @@ box_closed_p2( sync_vars_t *svars, int t )
// of interruption - in particular skipping messages would otherwise
// up the limit too early.
if (svars->maxuid[t] != svars->oldmaxuid[t])
JLOG( "N %d %u", (t, svars->maxuid[t]), "up maxuid of %s", str_fn[t] );
PC_JLOG( "N %d %u", (t, svars->maxuid[t]), "up maxuid of %s", str_fn[t] );
}
if (((svars->state[F] | svars->state[N]) & ST_DID_EXPUNGE) || svars->chan->max_messages) {
@ -1746,14 +1746,14 @@ box_closed_p2( sync_vars_t *svars, int t )
if (!srec->uid[N] || ((srec->status & S_DEL(N)) && (svars->state[N] & ST_DID_EXPUNGE))) {
if (!srec->uid[F] || ((srec->status & S_DEL(F)) && (svars->state[F] & ST_DID_EXPUNGE)) ||
((srec->status & S_EXPIRED) && svars->maxuid[F] >= srec->uid[F] && svars->maxxfuid >= srec->uid[F])) {
JLOG( "- %u %u", (srec->uid[F], srec->uid[N]), "killing" );
PC_JLOG( "- %u %u", (srec->uid[F], srec->uid[N]), "killing" );
srec->status = S_DEAD;
} else if (srec->uid[N]) {
JLOG( "> %u %u 0", (srec->uid[F], srec->uid[N]), "orphaning" );
PC_JLOG( "> %u %u 0", (srec->uid[F], srec->uid[N]), "orphaning" );
srec->uid[N] = 0;
}
} else if (srec->uid[F] && ((srec->status & S_DEL(F)) && (svars->state[F] & ST_DID_EXPUNGE))) {
JLOG( "< %u %u 0", (srec->uid[F], srec->uid[N]), "orphaning" );
PC_JLOG( "< %u %u 0", (srec->uid[F], srec->uid[N]), "orphaning" );
srec->uid[F] = 0;
}
}

View File

@ -72,17 +72,22 @@ void delete_state( sync_vars_t *svars );
void ATTR_PRINTFLIKE(2, 3) jFprintf( sync_vars_t *svars, const char *msg, ... );
#define JLOG_(log_fmt, log_args, dbg_fmt, ...) \
#define JLOG_(pre_commit, log_fmt, log_args, dbg_fmt, ...) \
do { \
if (pre_commit && !(DFlags & FORCEJOURNAL)) { \
debug( "-> (log: " log_fmt ") (" dbg_fmt ")\n", __VA_ARGS__ ); \
} else { \
debug( "-> log: " log_fmt " (" dbg_fmt ")\n", __VA_ARGS__ ); \
jFprintf( svars, log_fmt "\n", deparen(log_args) ); \
} \
} while (0)
#define JLOG3(log_fmt, log_args, dbg_fmt) \
JLOG_(log_fmt, log_args, dbg_fmt, deparen(log_args))
#define JLOG4(log_fmt, log_args, dbg_fmt, dbg_args) \
JLOG_(log_fmt, log_args, dbg_fmt, deparen(log_args), deparen(dbg_args))
#define JLOG3(pre_commit, log_fmt, log_args, dbg_fmt) \
JLOG_(pre_commit, log_fmt, log_args, dbg_fmt, deparen(log_args))
#define JLOG4(pre_commit, log_fmt, log_args, dbg_fmt, dbg_args) \
JLOG_(pre_commit, log_fmt, log_args, dbg_fmt, deparen(log_args), deparen(dbg_args))
#define JLOG_SEL(_1, _2, _3, _4, x, ...) x
#define JLOG(...) JLOG_SEL(__VA_ARGS__, JLOG4, JLOG3, NO_JLOG2, NO_JLOG1)(__VA_ARGS__)
#define JLOG(...) JLOG_SEL(__VA_ARGS__, JLOG4, JLOG3, NO_JLOG2, NO_JLOG1)(0, __VA_ARGS__)
#define PC_JLOG(...) JLOG_SEL(__VA_ARGS__, JLOG4, JLOG3, NO_JLOG2, NO_JLOG1)(1, __VA_ARGS__)
void assign_uid( sync_vars_t *svars, sync_rec_t *srec, int t, uint uid );