IMAP sync tool (rsync for IMAP)

Bron Gondwana brong at
Tue Dec 26 21:07:47 EST 2006

On Tue, 26 Dec 2006 14:45:43 -0800, "Florin Andrei" <florin at> said:
> John Capo wrote:
> > 
> > A 32MB message occupies a lot more than 32MB when its a Perl string.
> > Use a temp file instead.
> > 
> >     my $message_file = "/tmp/xfer-$$";
> >     unlink($message_file);
> >     $from->message_to_file($message_file, $f_msg);
> > 
> > And further down.
> > 
> >    unless($new_id = $to->append_file($t_fold, $message_file, $flags_f, $d))
> > 
> > Instead of 
> > 
> >    unless($new_id = $to->append_string($t_fold,$string, $flags_f, $d))
> It's hard to tell without actually testing that change, but I assume it 
> would slow down the script a little bit?
> Anyway, slower is better than crashing. I'll try and contact the author 
> to make him aware of this discussion thread.

The usual way to deal with this if you still care about speed is to check
the message size before hand (presumably you've already done a fetch of
the UID list to work out what needs to be copied - just grab the rfc822.size
field as well).

Then pick some sane amount (say, 100kb) and any message bigger than that
goes to disk - smaller messages can be processed directly in memory.

That said, most modern filesystems are pretty good about not causing
excessive IO for temporary files, and /tmp/ could very well be a memory
disk anyway (we have /tmpfs/ for precisely this sort of purpose)

(that and: unless your IMAP servers are really closely network connected
the network IO is going to be your critical path anyway)

  Bron Gondwana
  brong at

More information about the Info-cyrus mailing list