From: Timo Sirainen Date: Fri, 29 Apr 2016 11:07:05 +0000 (+0300) Subject: lib-index: Use a bit larger initial records buffer size X-Git-Tag: 2.3.0.rc1~3911 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=749097cae4e02bdeccb8b09f7dda6e2da6812ee1;p=thirdparty%2Fdovecot%2Fcore.git 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. --- diff --git a/src/lib-index/mail-index-map.c b/src/lib-index/mail-index-map.c index 52f9ad02ab..f3b14f2487 100644 --- a/src/lib-index/mail-index-map.c +++ b/src/lib-index/mail-index-map.c @@ -327,7 +327,9 @@ static void mail_index_map_copy_records(struct mail_index_record_map *dest, 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);