Skip to content

Commit

Permalink
lib-index: Use a bit larger initial records buffer size
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sirainen committed Apr 29, 2016
1 parent 7af8149 commit bc5f5fc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib-index/mail-index-map.c
Expand Up @@ -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);
Expand Down

0 comments on commit bc5f5fc

Please sign in to comment.