[Dovecot] Why p_strdup and other string functions uses loops instead strlen? (dovecot 2.0.rc4)
Len7hir
len7hir at gmail.com
Tue Aug 10 12:30:23 EEST 2010
I did Dovecot profiling on huge e-mail system, and p_strdup was very
high on list.
I do minor change:
p_strdup:
/*
for (len = 0; (str)[len] != '\0'; )
len++;
len++;
*/
len = strlen(str) + 1;
p_strndup:
/*
len = 0;
while (len < max_chars && ((const char *) str)[len] != '\0')
len++;
*/
len = strnlen(str, max_chars);
And after changes strdup drop down on the profile list.
This is output from oprofile:
samples % symbol name
28000 10.9764 p_strdup
8507 3.3349 safe_memset
7857 3.0801 .plt
7627 2.9899 buffer_write
6871 2.6935 parse_body_add_block
And after (about four times smaller samples, but shows everything):
samples % symbol name
9595 26.2625 parse_next_body_to_boundary
8247 22.5729 parse_body_add_block
772 2.1130 .plt
672 1.8393 buffer_write
658 1.8010 __i686.get_pc_thunk.bx
614 1.6806 safe_memset
586 1.6039 pool_alloconly_malloc
559 1.5300 p_strdup
533 1.4589 hash_table_insert_node
I wonder why You use loops instead strlen, which is optimalised on every
platforms.
Redgards,
Len7hir
More information about the dovecot
mailing list