[dovecot-cvs] dovecot/src/lib-index mail-index-private.h, 1.5, 1.6 mail-index-sync-update.c, 1.5, 1.6

cras at procontrol.fi cras at procontrol.fi
Wed Apr 28 22:41:23 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv12933/lib-index

Modified Files:
	mail-index-private.h mail-index-sync-update.c 
Log Message:
when growing index file, do it exponentially for this session (files being
added one at a time).



Index: mail-index-private.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mail-index-private.h	28 Apr 2004 18:52:06 -0000	1.5
+++ mail-index-private.h	28 Apr 2004 19:41:21 -0000	1.6
@@ -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;

Index: mail-index-sync-update.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mail-index-sync-update.c	28 Apr 2004 19:16:23 -0000	1.5
+++ mail-index-sync-update.c	28 Apr 2004 19:41:21 -0000	1.6
@@ -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()");
 



More information about the dovecot-cvs mailing list