MMAP performance and using mmap writes

Bron Gondwana brong at fastmailteam.com
Thu Nov 29 22:26:35 EST 2018


Hi All, 
 
We were debugging the CPU usage in a ctl_conversationsdb rebuild yesterday, and noticed an interesting thing. 70% of the CPU utilisation for this one process was inside the kernel! Mostly with dirty pages. 
 
ctl_conversationsdb -R is particularly heavy on the twoskip database - it's rewriting a lot of random keys. This leads to writes all over the place, as it stitches records into the skiplists. 
 
Of course the "real answer"[tm] is zeroskip, which doesn't do random writes - but until then, we suspect that the cost is largely due to the face that we use mmap to read, and fwrite to write! We know that might be less efficient already from Linus' comments about 10 years ago! And I guess here's the proof. 
 
An option would be to switch to using mmap to write as well. We could easily modify lib/mappedfile to memcpy to do the writes. 
 
Does anybody see any strong reason not to? 
 
Bron. 
 
-- 
 Bron Gondwana, CEO, FastMail Pty Ltd 
 brong at fastmailteam.com 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/cyrus-devel/attachments/20181129/7b134ff6/attachment.html>


More information about the Cyrus-devel mailing list