[dovecot-cvs] dovecot/src/lib-index mail-index-private.h, 1.13, 1.14 mail-index-sync-update.c, 1.11, 1.12 mail-index.c, 1.117, 1.118 mail-index.h, 1.105, 1.106

cras at procontrol.fi cras at procontrol.fi
Mon May 3 17:22:26 EEST 2004


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

Modified Files:
	mail-index-private.h mail-index-sync-update.c mail-index.c 
	mail-index.h 
Log Message:
INDEX_KEYWORDS_BYTE_COUNT was counted wrong so index files were larger than
they needed to be. Added sizeof(keywords_mask_t) to compat_data. Added limit
to growing index file exponentially.



Index: mail-index-private.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- mail-index-private.h	1 May 2004 16:30:58 -0000	1.13
+++ mail-index-private.h	3 May 2004 14:22:24 -0000	1.14
@@ -6,23 +6,13 @@
 
 struct mail_transaction_header;
 
-/* number of records to always keep allocated in index file,
-   either used or unused */
-#define INDEX_MIN_RECORDS_COUNT 64
-/* when empty space in index file gets full, grow the file n% larger */
-#define INDEX_GROW_PERCENTAGE 10
-/* ftruncate() the index file when only n% of it is in use */
-#define INDEX_TRUNCATE_PERCENTAGE 30
-/* don't truncate whole file anyway, keep n% of the empty space */
-#define INDEX_TRUNCATE_KEEP_PERCENTAGE 10
-/* Compress the file when deleted space reaches n% of total size */
-#define INDEX_COMPRESS_PERCENTAGE 50
-/* Compress the file when searching deleted records tree has to go this deep */
-#define INDEX_COMPRESS_DEPTH 10
+/* Index file is grown exponentially when we're adding less than this many
+   records. */
+#define MAIL_INDEX_MAX_POWER_GROW (1024*1024 / sizeof(struct mail_index_record))
 /* How many times to retry opening index files if read/fstat returns ESTALE.
    This happens with NFS when the file has been deleted (ie. index file was
    rewritten by another computer than us). */
-#define INDEX_ESTALE_RETRY_COUNT 10
+#define MAIL_INDEX_ESTALE_RETRY_COUNT 10
 
 #define MAIL_INDEX_MAP_IS_IN_MEMORY(map) \
 	((map)->buffer != NULL)

Index: mail-index-sync-update.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- mail-index-sync-update.c	2 May 2004 20:32:16 -0000	1.11
+++ mail-index-sync-update.c	3 May 2004 14:22:24 -0000	1.12
@@ -116,7 +116,8 @@
 	/* when we grow fast, do it exponentially */
 	if (count < index->last_grow_count)
 		count = index->last_grow_count;
-	count = nearest_power(count);
+	if (count < MAIL_INDEX_MAX_POWER_GROW)
+		count = nearest_power(count);
 	index->last_grow_count = count;
 
 	size = map->hdr->header_size +

Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- mail-index.c	1 May 2004 18:30:35 -0000	1.117
+++ mail-index.c	3 May 2004 14:22:24 -0000	1.118
@@ -49,6 +49,7 @@
 #endif
 	compat_data[1] = sizeof(uoff_t);
 	compat_data[2] = sizeof(time_t);
+	compat_data[3] = sizeof(keywords_mask_t);
 
 	if (hdr->major_version != MAIL_INDEX_MAJOR_VERSION) {
 		/* major version change - handle silently(?) */
@@ -233,7 +234,7 @@
 {
 	int i, ret;
 
-	for (i = 0; i < INDEX_ESTALE_RETRY_COUNT; i++) {
+	for (i = 0; i < MAIL_INDEX_ESTALE_RETRY_COUNT; i++) {
 		ret = mail_index_read_map(index, map);
 		if (ret != 0)
 			return ret;
@@ -359,6 +360,7 @@
 #endif
 	hdr->compat_data[1] = sizeof(uoff_t);
 	hdr->compat_data[2] = sizeof(time_t);
+	hdr->compat_data[3] = sizeof(keywords_mask_t);
 
 	hdr->indexid = now;
 

Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- mail-index.h	2 May 2004 20:32:16 -0000	1.105
+++ mail-index.h	3 May 2004 14:22:24 -0000	1.106
@@ -10,7 +10,7 @@
 
 /* Number of keywords in mail_index_record. */
 #define INDEX_KEYWORDS_COUNT (3*8)
-#define INDEX_KEYWORDS_BYTE_COUNT ((INDEX_KEYWORDS_COUNT*7)/8)
+#define INDEX_KEYWORDS_BYTE_COUNT ((INDEX_KEYWORDS_COUNT+CHAR_BIT-1) / CHAR_BIT)
 
 enum mail_index_open_flags {
 	/* Create index if it doesn't exist */



More information about the dovecot-cvs mailing list