dovecot-1.1: Sort index optimization: Don't write changes to sor...

dovecot at dovecot.org dovecot at dovecot.org
Thu May 29 18:51:14 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/ea913434d522
changeset: 7569:ea913434d522
user:      Timo Sirainen <tss at iki.fi>
date:      Thu May 29 18:49:55 2008 +0300
description:
Sort index optimization: Don't write changes to sort IDs if we're doing it
only to give sort ID space to expunged messages.

diffstat:

1 file changed, 15 insertions(+)
src/lib-storage/index/index-sort-string.c |   15 +++++++++++++++

diffs (39 lines):

diff -r 66e6b61680a5 -r ea913434d522 src/lib-storage/index/index-sort-string.c
--- a/src/lib-storage/index/index-sort-string.c	Thu May 29 18:47:46 2008 +0300
+++ b/src/lib-storage/index/index-sort-string.c	Thu May 29 18:49:55 2008 +0300
@@ -34,6 +34,7 @@ struct sort_string_context {
 	unsigned int first_missing_sort_id_idx;
 
 	uint32_t ext_id, last_seq, highest_reset_id;
+	uint32_t lowest_nonexpunged_zero;
 
 	unsigned int regetting:1;
 	unsigned int have_all_wanted:1;
@@ -157,6 +158,14 @@ static void index_sort_node_add(struct s
 		node->sort_id = 0;
 	} else {
 		node->sort_id = data == NULL ? 0 : *(const uint32_t *)data;
+		if (node->sort_id == 0) {
+			if (ctx->lowest_nonexpunged_zero > node->seq ||
+			    ctx->lowest_nonexpunged_zero == 0)
+				ctx->lowest_nonexpunged_zero = node->seq;
+		} else {
+			i_assert(ctx->lowest_nonexpunged_zero == 0 ||
+				 ctx->lowest_nonexpunged_zero > node->seq);
+		}
 	}
 
 	if (node->sort_id != 0) {
@@ -669,6 +678,12 @@ static void index_sort_add_missing(struc
 			next_seq = seqs[i] + 1;
 		}
 	}
+
+	if (ctx->lowest_nonexpunged_zero == 0) {
+		/* we're handling only expunged zeros. if it causes us to
+		   renumber some existing sort IDs, don't save them. */
+		ctx->no_writing = TRUE;
+	}
 }
 
 void index_sort_list_finish_string(struct mail_search_sort_program *program)


More information about the dovecot-cvs mailing list