dovecot-2.0: Memory usage optimizations.

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 15 05:38:45 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/1d6e99a9703f
changeset: 10728:1d6e99a9703f
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 15 05:38:42 2010 +0200
description:
Memory usage optimizations.

diffstat:

 src/dsync/dsync-worker-local.c            |   9 +++-
 src/dsync/dsync-worker.c                  |  38 +++++++++++++------
 src/lib-storage/index/index-transaction.c |   3 +-
 src/lib-storage/mail-storage.c            |   6 ++-
 src/lib-storage/mailbox-list.c            |  16 ++++++-
 5 files changed, 53 insertions(+), 19 deletions(-)

diffs (218 lines):

diff -r 6a8db6824157 -r 1d6e99a9703f src/dsync/dsync-worker-local.c
--- a/src/dsync/dsync-worker-local.c	Mon Feb 15 05:22:19 2010 +0200
+++ b/src/dsync/dsync-worker-local.c	Mon Feb 15 05:38:42 2010 +0200
@@ -19,6 +19,7 @@
 
 struct local_dsync_worker_mailbox_iter {
 	struct dsync_worker_mailbox_iter iter;
+	pool_t ret_pool;
 	struct mailbox_list_iterate_context *list_iter;
 	struct hash_iterate_context *deleted_iter;
 	struct hash_iterate_context *deleted_dir_iter;
@@ -389,6 +390,7 @@
 
 	iter = i_new(struct local_dsync_worker_mailbox_iter, 1);
 	iter->iter.worker = _worker;
+	iter->ret_pool = pool_alloconly_create("local mailbox iter", 1024);
 	iter->list_iter =
 		mailbox_list_iter_init_namespaces(worker->user->namespaces,
 						  patterns, list_flags);
@@ -532,10 +534,12 @@
 	dsync_box_r->uid_next = status.uidnext;
 	dsync_box_r->highest_modseq = status.highest_modseq;
 
+	p_clear(iter->ret_pool);
 	fields = array_get(status.cache_fields, &field_count);
-	t_array_init(&dsync_box_r->cache_fields, field_count);
+	p_array_init(&dsync_box_r->cache_fields, iter->ret_pool, field_count);
 	for (i = 0; i < field_count; i++) {
-		const char *field_name = t_strdup(fields[i]);
+		const char *field_name = p_strdup(iter->ret_pool, fields[i]);
+
 		array_append(&dsync_box_r->cache_fields, &field_name, 1);
 	}
 
@@ -554,6 +558,7 @@
 
 	if (mailbox_list_iter_deinit(&iter->list_iter) < 0)
 		ret = -1;
+	pool_unref(&iter->ret_pool);
 	i_free(iter);
 	return ret;
 }
diff -r 6a8db6824157 -r 1d6e99a9703f src/dsync/dsync-worker.c
--- a/src/dsync/dsync-worker.c	Mon Feb 15 05:22:19 2010 +0200
+++ b/src/dsync/dsync-worker.c	Mon Feb 15 05:38:42 2010 +0200
@@ -50,7 +50,12 @@
 int dsync_worker_mailbox_iter_next(struct dsync_worker_mailbox_iter *iter,
 				   struct dsync_mailbox *dsync_box_r)
 {
-	return iter->worker->v.mailbox_iter_next(iter, dsync_box_r);
+	int ret;
+
+	T_BEGIN {
+		ret = iter->worker->v.mailbox_iter_next(iter, dsync_box_r);
+	} T_END;
+	return ret;
 }
 
 int dsync_worker_mailbox_iter_deinit(struct dsync_worker_mailbox_iter **_iter)
@@ -127,23 +132,26 @@
 	i_assert(dsync_box->uid_validity != 0 ||
 		 dsync_mailbox_is_noselect(dsync_box));
 
-	if (!worker->readonly)
+	if (!worker->readonly) T_BEGIN {
 		worker->v.create_mailbox(worker, dsync_box);
+	} T_END;
 }
 
 void dsync_worker_delete_mailbox(struct dsync_worker *worker,
 				 const struct dsync_mailbox *dsync_box)
 {
-	if (!worker->readonly)
+	if (!worker->readonly) T_BEGIN {
 		worker->v.delete_mailbox(worker, dsync_box);
+	} T_END;
 }
 
 void dsync_worker_rename_mailbox(struct dsync_worker *worker,
 				 const mailbox_guid_t *mailbox,
 				 const struct dsync_mailbox *dsync_box)
 {
-	if (!worker->readonly)
+	if (!worker->readonly) T_BEGIN {
 		worker->v.rename_mailbox(worker, mailbox, dsync_box);
+	} T_END;
 }
 
 void dsync_worker_update_mailbox(struct dsync_worker *worker,
@@ -157,8 +165,10 @@
 void dsync_worker_select_mailbox(struct dsync_worker *worker,
 				 const struct dsync_mailbox *box)
 {
-	worker->v.select_mailbox(worker, &box->mailbox_guid,
-				 &box->cache_fields);
+	T_BEGIN {
+		worker->v.select_mailbox(worker, &box->mailbox_guid,
+					 &box->cache_fields);
+	} T_END;
 }
 
 void dsync_worker_msg_update_metadata(struct dsync_worker *worker,
@@ -188,8 +198,10 @@
 			   void *context)
 {
 	if (!worker->failed && !worker->readonly) {
-		worker->v.msg_copy(worker, src_mailbox, src_uid, dest_msg,
-				   callback, context);
+		T_BEGIN {
+			worker->v.msg_copy(worker, src_mailbox, src_uid,
+					   dest_msg, callback, context);
+		} T_END;
 	} else {
 		callback(FALSE, context);
 	}
@@ -200,8 +212,9 @@
 			   const struct dsync_msg_static_data *data)
 {
 	if (!worker->readonly) {
-		if (!worker->failed)
+		if (!worker->failed) T_BEGIN {
 			worker->v.msg_save(worker, msg, data);
+		} T_END;
 	} else {
 		const unsigned char *d;
 		size_t size;
@@ -222,10 +235,11 @@
 {
 	i_assert(uid != 0);
 
-	if (!worker->failed)
+	if (worker->failed)
+		callback(DSYNC_MSG_GET_RESULT_FAILED, NULL, context);
+	else T_BEGIN {
 		worker->v.msg_get(worker, mailbox, uid, callback, context);
-	else
-		callback(DSYNC_MSG_GET_RESULT_FAILED, NULL, context);
+	} T_END;
 }
 
 void dsync_worker_finish(struct dsync_worker *worker,
diff -r 6a8db6824157 -r 1d6e99a9703f src/lib-storage/index/index-transaction.c
--- a/src/lib-storage/index/index-transaction.c	Mon Feb 15 05:22:19 2010 +0200
+++ b/src/lib-storage/index/index-transaction.c	Mon Feb 15 05:38:42 2010 +0200
@@ -116,7 +116,8 @@
 	int ret;
 
 	memset(changes_r, 0, sizeof(*changes_r));
-	changes_r->pool = pool_alloconly_create("transaction changes", 1024);
+	changes_r->pool = pool_alloconly_create(MEMPOOL_GROWING
+						"transaction changes", 512);
 	p_array_init(&changes_r->saved_uids, changes_r->pool, 32);
 	_t->changes = changes_r;
 
diff -r 6a8db6824157 -r 1d6e99a9703f src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c	Mon Feb 15 05:22:19 2010 +0200
+++ b/src/lib-storage/mail-storage.c	Mon Feb 15 05:38:42 2010 +0200
@@ -1126,11 +1126,15 @@
 	struct mail_transaction_commit_changes *changes_r)
 {
 	struct mailbox_transaction_context *t = *_t;
+	int ret;
 
 	t->box->transaction_count--;
 
 	*_t = NULL;
-	return t->box->v.transaction_commit(t, changes_r);
+	T_BEGIN {
+		ret = t->box->v.transaction_commit(t, changes_r);
+	} T_END;
+	return ret;
 }
 
 void mailbox_transaction_rollback(struct mailbox_transaction_context **_t)
diff -r 6a8db6824157 -r 1d6e99a9703f src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c	Mon Feb 15 05:22:19 2010 +0200
+++ b/src/lib-storage/mailbox-list.c	Mon Feb 15 05:38:42 2010 +0200
@@ -464,19 +464,29 @@
 bool mailbox_list_is_valid_pattern(struct mailbox_list *list,
 				   const char *pattern)
 {
-	return list->v.is_valid_pattern(list, pattern);
+	bool ret;
+
+	T_BEGIN {
+		ret = list->v.is_valid_pattern(list, pattern);
+	} T_END;
+	return ret;
 }
 
 bool mailbox_list_is_valid_existing_name(struct mailbox_list *list,
 					 const char *name)
 {
+	bool ret;
+
 	if (*name == '\0' && *list->ns->prefix != '\0') {
 		/* an ugly way to get to mailbox root (e.g. Maildir/ when
 		   it's not the INBOX) */
 		return TRUE;
 	}
 
-	return list->v.is_valid_existing_name(list, name);
+	T_BEGIN {
+		ret = list->v.is_valid_existing_name(list, name);
+	} T_END;
+	return ret;
 }
 
 bool mailbox_list_is_valid_create_name(struct mailbox_list *list,
@@ -619,7 +629,7 @@
 
 	i_assert(namespaces != NULL);
 
-	pool = pool_alloconly_create("mailbox list namespaces", 512);
+	pool = pool_alloconly_create("mailbox list namespaces", 1024);
 	ctx = p_new(pool, struct ns_list_iterate_context, 1);
 	ctx->pool = pool;
 	ctx->ctx.flags = flags;


More information about the dovecot-cvs mailing list