changeset 20100:1a75fdc0744a

lib-index: Use a bit larger initial records buffer size For example with a mailbox having 160k messages the buffer size is around 10MB. Adding just 1% more space to it allows a lot more appends before the buffer needs to be realloced. This reduces CPU usage quite a lot.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Fri, 29 Apr 2016 14:07:05 +0300
parents c89167e445fd
children a0a751e444d3
files src/lib-index/mail-index-map.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-map.c	Fri Apr 29 13:55:33 2016 +0300
+++ b/src/lib-index/mail-index-map.c	Fri Apr 29 14:07:05 2016 +0300
@@ -327,7 +327,9 @@
 	size_t size;
 
 	size = src->records_count * record_size;
-	dest->buffer = buffer_create_dynamic(default_pool, I_MAX(size, 1024));
+	/* +1% so we have a bit of space to grow. useful for huge mailboxes. */
+	dest->buffer = buffer_create_dynamic(default_pool,
+					     size + I_MAX(size/100, 1024));
 	buffer_append(dest->buffer, src->records, size);
 
 	dest->records = buffer_get_modifiable_data(dest->buffer, NULL);