I’ve been very annoyed with my Mac for a while now. It seemed to take an inordinate amount of time get my working set of applications open and ready after a reboot (which sadly happen at least once a week). I timed it at 10 minutes once.
Eventually, after some experimenting, I narrowed it down to Apple Mail sucking up system resources on start-up and causing the entire system to get sluggish.
I finally got around to resolving the problem. It boiled down to the following:
SpamSieve, my spam handling plug-in for Mail, had a much larger dataset (“spam corpus”, the central database for determining whether an email is spam) than it should have. I reset it, retrained it, and cleared out some of the other data structures. Because Mail blocks on SpamSieve after it receives two emails, this led to Mail starting up faster. This will also lead to a smaller memory footprint at run time and/or faster spam-marking performance. Because I get a ton of spam a day, this goes a long way towards making Mail faster.
My spam folder had reached over 140,000 emails. Because SpamSieve doesn’t use Mail’s default spam mechanism, Mail doesn’t auto-delete SpamSieve’s spam folder. As a result, it just grew and grew and grew. Furthermore, Mail didn’t know that all this mail was in a spam folder; it was just another folder than some third-party rule was populating. Thus, any optimizations Mail has to treat spam as a second-class citizen weren’t be performed (if any).
Deleting the spam through the GUI would have taken a long time (trust me), so I blew it away in the file system. Instantly, Mail became much more responsive because it turns out simply marking email as spam causes a 1-2 second UI delay when the spam folder has so many pieces of mail.
To prevent this from happening in the future, I turned on Mail’s spam filter (but effectively disabled it by setting a custom non-sense rule) and I know route SpamSieve’s spam to Mail’s spam filter, which among other things means that I could configure Mail to auto-delete the spam folder every month.
Partly because of all this spam, Mail’s index database was over 100 MB (after vacuuming). Undoubtedly, this was also causing some sluggishness. I blew away the index database and let Mail rebuild it.
After all this, Mail is like a whole new application: totally responsive and fast to start up. This is turn has resulted in my system becoming usable much sooner after a reboot — and has eliminated a bunch of lag while I used Mail. Woohoo!
And that’s not all. After making these changes, using my Mac is a whole new experience. Applications launch faster, searches in Mail are instantaneous, everything works faster. MenuMeters failed to convey the massive performance hit that SpamSieve and Apple Mail (and the SQLite run-time) were incurring on my system. Wow.