dovecot-2.1: lib-storage: Update search's cost more widely and l...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Mar 10 15:53:55 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/00887de4ad32
changeset: 14283:00887de4ad32
user: Timo Sirainen <tss at iki.fi>
date: Sat Mar 10 15:44:27 2012 +0200
description:
lib-storage: Update search's cost more widely and less often.
diffstat:
src/lib-storage/index/index-search.c | 31 ++++++++++++++++++++-----------
1 files changed, 20 insertions(+), 11 deletions(-)
diffs (69 lines):
diff -r 4a82ff720781 -r 00887de4ad32 src/lib-storage/index/index-search.c
--- a/src/lib-storage/index/index-search.c Sat Mar 10 15:07:23 2012 +0200
+++ b/src/lib-storage/index/index-search.c Sat Mar 10 15:44:27 2012 +0200
@@ -1220,17 +1220,12 @@
static int search_match_once(struct index_search_context *ctx)
{
- unsigned long long cost1, cost2;
int ret;
- cost1 = search_get_cost(ctx->cur_mail->transaction);
ret = mail_search_args_foreach(ctx->mail_ctx.args->args,
search_cached_arg, ctx);
if (ret < 0)
ret = search_arg_match_text(ctx->mail_ctx.args->args, ctx);
-
- cost2 = search_get_cost(ctx->cur_mail->transaction);
- ctx->cost += cost2 - cost1;
return ret;
}
@@ -1423,7 +1418,8 @@
struct mail_search_context *_ctx = &ctx->mail_ctx;
struct mailbox *box = _ctx->transaction->box;
struct index_mail *imail = (struct index_mail *)mail;
- int match;
+ unsigned long long cost1, cost2;
+ int match, ret;
if (search_would_block(ctx)) {
/* this lookup is useful when a large number of
@@ -1437,6 +1433,8 @@
mail_search_args_reset(_ctx->args->args, FALSE);
+ cost1 = search_get_cost(mail->transaction);
+ ret = -1;
while (box->v.search_next_update_seq(_ctx)) {
mail_set_seq(mail, _ctx->seq);
@@ -1458,12 +1456,23 @@
mail_search_args_reset(_ctx->args->args, FALSE);
- if (match != 0)
- return 1;
- if (search_would_block(ctx))
- return 0;
+ if (match != 0) {
+ ret = 1;
+ break;
+ }
+
+ cost2 = search_get_cost(mail->transaction);
+ ctx->cost += cost2 - cost1;
+ cost1 = cost2;
+
+ if (search_would_block(ctx)) {
+ ret = 0;
+ break;
+ }
}
- return -1;
+ cost2 = search_get_cost(mail->transaction);
+ ctx->cost += cost2 - cost1;
+ return ret;
}
struct mail *index_search_get_mail(struct index_search_context *ctx)
More information about the dovecot-cvs
mailing list