karelzak / mutt-kz

mutt-kz is DEPRECATED in favor of neomutt project.
https://neomutt.org
Other
296 stars 51 forks source link

Use unlocked libc IO everywhere. #68

Closed dw closed 10 years ago

dw commented 10 years ago

Since mutt does not use threads, there is no reason it should use the locked variants of the FILE* IO functions. This checks if the unlocked functions are available, and if so enables them globally via mutt.h.

Cuts load time for a 56k message, 1.8GB /var/mail mailbox from 14 seconds to ~6 seconds, since we avoid acquiring and releasing a mutex for every character of input read.

Before: 0m14.376s

74.98%          mutt  libc-2.18.so        [.] _IO_getc
11.87%          mutt  mutt                [.] mbox_parse_mailbox
 0.94%          mutt  [kernel.kallsyms]   [k] copy_user_generic_string
 0.83%          mutt  libc-2.18.so        [.] __strchr_sse2
 0.53%          mutt  libc-2.18.so        [.] __memcpy_sse2
 0.44%          mutt  libc-2.18.so        [.] _int_malloc

After: 6 seconds

68.92%     mutt  mutt                  [.] mbox_parse_mailbox
 2.25%     mutt  [kernel.kallsyms]     [k] copy_user_generic_string
 1.73%     mutt  libc-2.18.so          [.] __strchr_sse2
 1.24%     mutt  libc-2.18.so          [.] __memcpy_sse2
 1.17%     mutt  libc-2.18.so          [.] _int_malloc
 0.87%     mutt  libc-2.18.so          [.] __strspn_sse42
dw commented 10 years ago

You can try it out on a huge mailbox here: http://k2.botanicus.net/qemu-all.mbox.bz2 ... warning 350mb download, extracts to 1.9GB

dw commented 10 years ago

How would you feel about a slightly more ambitious refactor of all the FILE* code? /bin/cat can read the mailbox in 200ms, I don't see why mutt needs much more than double that...