From 2f4b71c56e3e6caa76a649018681704628405108 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 18 Feb 2022 17:45:01 +0100 Subject: [PATCH] knock out ReNew if there are no dummies the operation requires loading the target side, which makes it somewhat expensive in otherwise unidirectional syncs. one could also knock out Flags and Delete if there are no living pairs, but that wouldn't actually save much. --- src/sync.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sync.c b/src/sync.c index ad8f44d..1e22889 100644 --- a/src/sync.c +++ b/src/sync.c @@ -680,14 +680,23 @@ box_opened2( sync_vars_t *svars, int t ) if (!lock_state( svars )) goto bail; + int any_dummies[2] = { 0, 0 }; int any_purges[2] = { 0, 0 }; int any_upgrades[2] = { 0, 0 }; int any_new[2] = { 0, 0 }; int any_tuids[2] = { 0, 0 }; - if (svars->replayed) { + if (svars->replayed || ((chan->ops[F] | chan->ops[N]) & OP_RENEW)) { for (srec = svars->srecs; srec; srec = srec->next) { if (srec->status & S_DEAD) continue; + if (srec->status & S_DUMMY(F)) + any_dummies[F]++; + else if (srec->status & S_DUMMY(N)) + any_dummies[N]++; + else if (srec->status & S_SKIPPED) + any_dummies[!srec->uid[F] ? F : N]++; + if (!svars->replayed) + continue; if (srec->status & S_PURGE) { any_purges[srec->uid[F] ? F : N]++; } else if (srec->status & S_PENDING) { @@ -721,6 +730,10 @@ box_opened2( sync_vars_t *svars, int t ) if (chan->ops[t] & OP_FLAGS) opts[t^1] |= OPEN_FLAGS; } + if (!any_dummies[t] && (chan->ops[t] & OP_RENEW)) { + chan->ops[t] &= ~OP_RENEW; + debug( "no %s dummies; masking ReNew\n", str_fn[t] ); + } if ((chan->ops[t] & (OP_NEW | OP_RENEW)) || any_new[t] || any_upgrades[t]) { opts[t] |= OPEN_APPEND; if ((chan->ops[t] & OP_NEW) || any_new[t]) {