Attached patch is a body prefetching proof of concept. Currently to display a message at least two FETCHes are called. The first for headers and bodystructure and the second for message body. In most cases we can skip second call and fetch message body in first call adding "BODY.PEEK[1]<0.2048>" to the list.
On my server I've got a negligible gain, because of very quick FETCH (dovecot 1.1) and not havy load, but I like to know how about yours. We could apply this as an option.
p.s. you can increase prefetch size changing 2048 to e.g. 4096 in the patch. Currently it's hardcoded.
A.L.E.C wrote:
Attached patch is a body prefetching proof of concept.
For those who want to test my patch. To make testing simpler, comment console in imap.inc. Then apply my second patch. Now open a few messages and check logs/console. You'll find there time spent for fetching message contents. "(prefetch used)" is added when prefetched body was used for display, it means, there was one FETCH less. After some tests with modified imap.inc, you can replace it with the old one and open again the same messages. Then you can just compare results.