I added a new mail_prefetch_count setting to Dovecot v2.1 (http://hg.dovecot.org/dovecot-2.1/). Its main purpose is to avoid unnecessary latency while waiting for replies from remote server with imapc, i.e. instead of doing (FETCH, wait, FETCH, wait, ...) it can do (FETCH, FETCH, .., wait). For the same reason it's also going to be very useful once I add support for key-value databases / other high latency cloud filesystems.
It also works with Maildir, single-dbox and cydir backends by calling posix_fadvise(POSIX_FADV_WILLNEED) for the files. This syscall is apparently only implemented by Linux. It should tell the kernel to start reading the files from disk to page cache. By calling this for multiple files, it should help the kernel optimize disk I/O. For example if 10 files are prefetched, the kernel might figure out that it should read them in a different order to avoid extra disk seeks. Perhaps it also does something useful with NFS, I don't know.
I'm not sure if it would be a good idea to use this for mbox or multi-dbox files, since they already have multiple messages in same file so kernel probably already did some prefetching. With mdbox I guess it could be useful if the message file changes..
This optimization currently works only for FETCH command (and POP3 RETR and TOP). SEARCH/THREAD/SORT commands will hopefully implement it soon also.
I'd be interested in knowing what the effects of this setting are if anyone tests this some day.
participants (1)
-
Timo Sirainen