]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
when growing index file, do it exponentially for this session (files being
authorTimo Sirainen <tss@iki.fi>
Wed, 28 Apr 2004 19:41:21 +0000 (22:41 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 28 Apr 2004 19:41:21 +0000 (22:41 +0300)
added one at a time).

--HG--
branch : HEAD

src/lib-index/mail-index-private.h
src/lib-index/mail-index-sync-update.c

index 0ba9c21607160268fdc84e00cca237f7591319e7..dcb04c36b1f36a56462eee959a7e253c10f3e627 100644 (file)
@@ -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;
index 6780ddde8b5e171307bab8271ea17ac86fa7f1d8..03a1287e5e8ab3c75c7a10149f5d73a598acd85f 100644 (file)
@@ -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()");