changeset 4980:8e88ecc64563 HEAD

debug: MEMPOOL_GROWING prefix in alloconly pool names means that when the memory pool needs to be grown, there's no need to log a warning.
author Timo Sirainen <tss@iki.fi>
date Fri, 29 Dec 2006 01:21:06 +0200
parents b51777b0834c
children 173c5ea4a7c4
files src/lib-storage/index/maildir/maildir-uidlist.c src/lib/mempool-alloconly.c src/lib/mempool.h
diffstat 3 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Fri Dec 29 01:19:54 2006 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Fri Dec 29 01:21:06 2006 +0200
@@ -302,7 +302,8 @@
 
 	if (uidlist->record_pool == NULL) {
 		uidlist->record_pool =
-			pool_alloconly_create("uidlist record_pool",
+			pool_alloconly_create(MEMPOOL_GROWING
+					      "uidlist record_pool",
 					      nearest_power(st.st_size -
 							    st.st_size/8));
 	}
@@ -684,8 +685,8 @@
 		return 1;
 	}
 
-	ctx->record_pool =
-		pool_alloconly_create("maildir_uidlist_sync", 16384);
+	ctx->record_pool = pool_alloconly_create(MEMPOOL_GROWING
+						 "maildir_uidlist_sync", 16384);
 	ctx->files = hash_create(default_pool, ctx->record_pool, 4096,
 				 maildir_hash, maildir_cmp);
 
@@ -716,7 +717,8 @@
 
 		if (uidlist->record_pool == NULL) {
 			uidlist->record_pool =
-				pool_alloconly_create("uidlist record_pool",
+				pool_alloconly_create(MEMPOOL_GROWING
+						      "uidlist record_pool",
 						      1024);
 		}
 
--- a/src/lib/mempool-alloconly.c	Fri Dec 29 01:19:54 2006 +0200
+++ b/src/lib/mempool-alloconly.c	Fri Dec 29 01:21:06 2006 +0200
@@ -23,6 +23,7 @@
 #ifdef DEBUG
 	const char *name;
 	size_t base_size;
+	bool disable_warning;
 #endif
 	bool clean_frees;
 };
@@ -110,6 +111,10 @@
 	new_apool = p_new(&apool.pool, struct alloconly_pool, 1);
 	*new_apool = apool;
 #ifdef DEBUG
+	if (strncmp(name, MEMPOOL_GROWING, strlen(MEMPOOL_GROWING)) == 0) {
+		name += strlen(MEMPOOL_GROWING);
+		new_apool->disable_warning = TRUE;
+	}
 	new_apool->name = p_strdup(&new_apool->pool, name);
 
 	/* set base_size so p_clear() doesn't trash alloconly_pool structure. */
@@ -195,8 +200,10 @@
 
 		size = nearest_power(size);
 #ifdef DEBUG
-		i_warning("Growing pool '%s' with: %"PRIuSIZE_T,
-			  apool->name, size);
+		if (!apool->disable_warning) {
+			i_warning("Growing pool '%s' with: %"PRIuSIZE_T,
+				  apool->name, size);
+		}
 #endif
 	}
 
--- a/src/lib/mempool.h	Fri Dec 29 01:19:54 2006 +0200
+++ b/src/lib/mempool.h	Fri Dec 29 01:21:06 2006 +0200
@@ -3,6 +3,13 @@
 
 #include "macros.h"
 
+/* When DEBUG is enabled, Dovecot warns whenever a memory pool is grown.
+   This is done so that the initial pool size could be set large enough so that
+   it wouldn't grow in normal use. For some memory pools it's too difficult
+   to calculate a good initial size, so this prefix should be used with those
+   pools to disable the warning. */
+#define MEMPOOL_GROWING "GROWING-"
+
 /* Memory allocated and reallocated (the new data in it) in pools is always
    zeroed, it will cost only a few CPU cycles and may well save some debug
    time. */