Recently I was talking with Dave about using ENVELOPE in stead of what Evolution’s Camel does for fetching the summary information. The camel-lite of tinymail, however, already reduced the query a lot by cutting away everything that was not being used.
Months ago I cut away headers like REFERENCES, IN-REPLY-TO, MIME-VERSION, CONTENT-TYPE and in some situations also X-MAILING-LIST, X-LOOP, LIST-ID, LIST-POST, MAILING-LIST, ORIGINATOR, X-LIST, SENDER, RETURN-PATH, X-BEENTHERE. Though that last list was conditional they do get received by most people’s Evolution. Only if you have put “basic_headers” in the “url string” of your IMAP account, this last list of headers isn’t used in Evolution.
In contrast with that I figured early on that an E-mail client for a mobile-device does not need all the information, per message, about the mailing list. The summary view was not showing the reply-to field and tinymail doesn’t yet support showing the headers in a thread view. Which is what the references header is used for.
I’m mentioning this because I want to get rid of the reputation that Evolution has when it comes to bandwidth utilization. Tinymail is using an extensively modified Camel for a reason, indeed.
This was before I learned about Lemonade. You must know that back when I started with tinymail, I was not very experienced in all this E-mail & IMAP stuff. I’m still not, nor is it easy to know everything about it.
I got an account on one of the Isode servers for testing. I used their server for testing this, because that server (I assume) is a very efficient one when it comes to interpreting the IMAP specification versus bandwidth utilization (they are one of the companies that are pushing Lemonade, hence the assumption).
The most efficient way to ask for the summary is probably to use something like this (Don’t worry, people like Dave are going to correct me if it’s wrong):
A01 UID FETCH 1:2 (UID FLAGS RFC822.SIZE ENVELOPE)
ENVELOPE is often cached information, so it’s fast. In bandwidth, which is what matters most for tinymail because IMAP “servers” usually have enough power when comparing it with a mobile device, this consumed something like 800 bytes depending on the headers themselves. I’ll use the actual numbers of the account that I got from Isode.
This, however, is what tinymail is using today. You don’t want to see the query that Evolution is using :-). In a few words, it’s something like three times larger in what it asks for. You can probably compare it with a “TOP uid 0” on a POP3 server (most headers). It’s not about bashing Evolution. I’m just comparing facts here.
A01 UID FETCH 1:2 (FLAGS RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (DATE FROM TO CC SUBJECT MESSAGE-ID)])
This consumed 825 bytes. Don’t forget that back when I was optimizing this, I wasn’t into writing a parser for ENVELOPE nor did I actually know about that IMAP feature. Remember: I was not very experienced with IMAP at all. My focus was on getting tinymail to do something interesting in terms of memory consumption while wrapping that in the nicest API that I can imagine. You know, I’m just one person with only two hands.
Luckily only a few of the things that are needed do consume a lot bandwidth. Important are receiving the summary, updating the flags and knowing about expunges and other such changes. In other words: synchronizing the local offline status with the online status.
And that is precisely what Lemonade is improving in the specification. Condstore, for example, returns me a sequence number that uniquely identifies the current status of the mailbox. I can create a very simple query that says: well, give me all changes that have happened since a state. Important here is that I only receive the changes. I don’t have to get all of it and start comparing things.
The difference of 25 bytes sure is significant enough to want to improve this. This will eventually happen. I also have to check whether using ENVELOPE on all IMAP servers works correctly of course. With worst-case servers around (experts know which server I mean), this isn’t self evident. This indeed, is what makes developing an IMAP client difficult. My opinion, and I like to express that as people already know, is that it’s better not to create an IMAP server than to create one that sucks. The problem is that users will depend on your defects. And that E-mail client developers need to cope with it.
So, why did I write this lengthy blog item?
Because I wanted to tell people not to get the focus of the tinymail framework wrong. Memory consumption is only one aspect of the project. Bandwidth utilization is actually even more important. Other aspects are design, testing, documentation, language bindings, flexibility and being adaptive to change.
By the way, didn’t I whine a lot about being adaptive to change a few months ago? I might have irritated some people, right? Guess what Lemonade brings us?
Change
This proofs my point. Once I implement support for the IDLE Lemonade feature, I already have a TnyFolderObserver type ready for this.
E-mail nor any other technology is in a stable state. E-mail has never been in that state though it’s one of the oldest Internet standards. Change is among us.
Be adaptive.