Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6695:76c0e3a4df7a HEAD
If we need to do more than 4 reads to get to the cached fields header,
compress the cache file.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 05 Nov 2007 21:37:27 +0200 |
parents | c7742d109a67 |
children | 68adf46a6b3f |
files | src/lib-index/mail-cache-fields.c src/lib-index/mail-cache-private.h |
diffstat | 2 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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,8 +215,12 @@ 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; }
--- 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 @@ -23,6 +23,10 @@ 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)