changeset 1928:5ca676060080 HEAD

when growing index file, do it exponentially for this session (files being added one at a time).
author Timo Sirainen <tss@iki.fi>
date Wed, 28 Apr 2004 22:41:21 +0300
parents 7ad1a47c615e
children e1443315294c
files src/lib-index/mail-index-private.h src/lib-index/mail-index-sync-update.c
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-private.h	Wed Apr 28 22:16:23 2004 +0300
+++ b/src/lib-index/mail-index-private.h	Wed Apr 28 22:41:21 2004 +0300
@@ -74,6 +74,8 @@
 	char *copy_lock_path;
 	struct dotlock dotlock;
 
+	unsigned int last_grow_count;
+
 	char *error;
 	unsigned int nodiskspace:1;
 	unsigned int index_lock_timeout:1;
--- a/src/lib-index/mail-index-sync-update.c	Wed Apr 28 22:16:23 2004 +0300
+++ b/src/lib-index/mail-index-sync-update.c	Wed Apr 28 22:41:21 2004 +0300
@@ -107,9 +107,13 @@
 		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()");