Gnus development mailing list
 help / color / mirror / Atom feed
From: Matthias Andree <ma@dt.e-technik.uni-dortmund.de>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: ding@gnus.org
Subject: Re: pop3 speedup
Date: Mon, 26 Sep 2011 22:01:47 +0200	[thread overview]
Message-ID: <4E80DA2B.1020409@dt.e-technik.uni-dortmund.de> (raw)
In-Reply-To: <m3pqinw19y.fsf@stories.gnus.org>

Am 26.09.2011 21:29, schrieb Lars Magne Ingebrigtsen:
> Matthias Andree <ma@dt.e-technik.uni-dortmund.de> writes:
> 
>> _exponential_? How does an algorithm for POP3 mail fetching with such a
>> complexity look like?
> 
> The old algorithm counted all the messages in the buffer from the start
> repeatedly while waiting for them all to arrive.  So if you fetched 1000
> messages, it would typically first count 10 messages, then it would
> count 20, then it would count 30, all the way up to 1000.
> 
> Hm.  Is that exponential?

No, squared, which is worse enough in this case. :-)

Watch (disregard small constant factors such as 2 or 1/2 or 5, only the
asymptotical growth matters):

n       n log n   n^2                 2^n
linear  lin-log   squared         exponential (base 2 here)

   3       5           9                   8
   5      12          25                  32
  10      33         100               1,024
  30     147         900       1,073,741,824
 100     664      10,000             1.26E30
1000   9,965   1,000,000            1.07E300

>> I've seen various awkward cases in POP3 or IMAP clients as worse as
>> O(n^2 * log n), but I can't possibly fancy how to attain O(e^n).
> 
> I know, I'm pretty awesome.  :-)

O(n^2) code is easily written (two nested loops with similar upper
bound) and quickly hurts when trying to scale software from the test
beds -- but you've got company there.  Some algorithms, such as checking
UID lists for "POP3 + leave messages on server", can't get better than
O(n log n) which is why I included that above.

-- 
Matthias Andree



      parent reply	other threads:[~2011-09-26 20:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-26 18:37 Lars Magne Ingebrigtsen
2011-09-26 19:16 ` Matthias Andree
2011-09-26 19:29   ` Lars Magne Ingebrigtsen
2011-09-26 19:34     ` Antoine Levitt
2011-09-26 19:35       ` Lars Magne Ingebrigtsen
2011-09-26 19:55         ` Antoine Levitt
2011-09-26 20:09           ` Matthias Andree
2011-09-26 20:01     ` Matthias Andree [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E80DA2B.1020409@dt.e-technik.uni-dortmund.de \
    --to=ma@dt.e-technik.uni-dortmund.de \
    --cc=ding@gnus.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).