I have seen how the incoming.pl is designed.
I must say, not agreeing at to other users about the Gmail in Beta, that the quality of programming is extra-ordinary developed to a very high value.
But I still think there needs to be some change in it. Those scripts below could be placed under cron. This will reduce tremendously the number of seconds in which the incoming.pl delivers a mail to the user. Lets say if there are couple of scripts that does different function, for e.g.
and also ...
Reduce Database connection