dovecot: If we need to do more than 4 reads to get to the cached...

dovecot at dovecot.org dovecot at dovecot.org
Mon Nov 5 21:38:25 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/76c0e3a4df7a
changeset: 6695:76c0e3a4df7a
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Nov 05 21:37:27 2007 +0200
description:
If we need to do more than 4 reads to get to the cached fields header,
compress the cache file.

diffstat:

2 files changed, 10 insertions(+), 1 deletion(-)
src/lib-index/mail-cache-fields.c  |    7 ++++++-
src/lib-index/mail-cache-private.h |    4 ++++

diffs (38 lines):

diff -r c7742d109a67 -r 76c0e3a4df7a src/lib-index/mail-cache-fields.c
--- a/src/lib-index/mail-cache-fields.c	Mon Nov 05 21:15:28 2007 +0200
+++ b/src/lib-index/mail-cache-fields.c	Mon Nov 05 21:37:27 2007 +0200
@@ -173,6 +173,7 @@ static int mail_cache_header_fields_get_
 	const unsigned int size = sizeof(*field_hdr) + CACHE_HDR_PREFETCH;
 	uint32_t offset, next_offset;
 	uoff_t invalid_start = 0, invalid_end = 0;
+	unsigned int next_count = 0;
 
 	if (MAIL_CACHE_IS_UNUSABLE(cache)) {
 		*offset_r = 0;
@@ -214,7 +215,11 @@ static int mail_cache_header_fields_get_
 		field_hdr = CONST_PTR_OFFSET(cache->data, offset);
 		next_offset =
 			mail_index_offset_to_uint32(field_hdr->next_offset);
-	}
+		next_count++;
+	}
+
+	if (next_count > MAIL_CACHE_HEADER_FIELD_CONTINUE_COUNT)
+		cache->need_compress_file_seq = cache->hdr->file_seq;
 
 	*offset_r = offset;
 	return 0;
diff -r c7742d109a67 -r 76c0e3a4df7a src/lib-index/mail-cache-private.h
--- a/src/lib-index/mail-cache-private.h	Mon Nov 05 21:15:28 2007 +0200
+++ b/src/lib-index/mail-cache-private.h	Mon Nov 05 21:37:27 2007 +0200
@@ -22,6 +22,10 @@
 /* Compress the file when n% of rows contain continued rows.
    200% means that there's 2 continued rows per record. */
 #define MAIL_CACHE_COMPRESS_CONTINUED_PERCENTAGE 200
+
+/* Compress the file when we need to follow more than n next_offsets to find
+   the latest cache header. */
+#define MAIL_CACHE_HEADER_FIELD_CONTINUE_COUNT 4
 
 /* Initial size for the file */
 #define MAIL_CACHE_INITIAL_SIZE (sizeof(struct mail_cache_header) + 10240)


More information about the dovecot-cvs mailing list