# HG changeset patch # User Timo Sirainen # Date 1194291447 -7200 # Node ID 76c0e3a4df7a758c99b97cb936ea121d8d428a8f # Parent c7742d109a672bb5ec252e726323291ceada2133 If we need to do more than 4 reads to get to the cached fields header, compress the cache file. 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 @@ 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; } 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 @@ -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)