From: Timo Sirainen Date: Wed, 28 Apr 2004 19:41:21 +0000 (+0300) Subject: when growing index file, do it exponentially for this session (files being X-Git-Tag: 1.1.alpha1~4178 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=690af4a90eaf8611c2573d34126bb7a852c50a44;p=thirdparty%2Fdovecot%2Fcore.git when growing index file, do it exponentially for this session (files being added one at a time). --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-index-private.h b/src/lib-index/mail-index-private.h index 0ba9c21607..dcb04c36b1 100644 --- a/src/lib-index/mail-index-private.h +++ b/src/lib-index/mail-index-private.h @@ -74,6 +74,8 @@ struct mail_index { char *copy_lock_path; struct dotlock dotlock; + unsigned int last_grow_count; + char *error; unsigned int nodiskspace:1; unsigned int index_lock_timeout:1; diff --git a/src/lib-index/mail-index-sync-update.c b/src/lib-index/mail-index-sync-update.c index 6780ddde8b..03a1287e5e 100644 --- a/src/lib-index/mail-index-sync-update.c +++ b/src/lib-index/mail-index-sync-update.c @@ -107,9 +107,13 @@ static int mail_index_grow(struct mail_index *index, unsigned int count) return 0; } - // FIXME: grow exponentially - size = map->file_used_size + - count * sizeof(struct mail_index_record); + /* when we grow fast, do it exponentially */ + if (count < index->last_grow_count) + count = index->last_grow_count; + count = nearest_power(count); + index->last_grow_count = count; + + size = map->file_used_size + count * sizeof(struct mail_index_record); if (file_set_size(index->fd, (off_t)size) < 0) return mail_index_set_syscall_error(index, "file_set_size()");