From: Andries Brouwer <aebr@win.tue.nl>
To: Hubertus Franke <frankeh@watson.ibm.com>
Cc: Linus Torvalds <torvalds@transmeta.com>,
Andrew Morton <akpm@zip.com.au>,
Paul Larson <plars@austin.ibm.com>,
lkml <linux-kernel@vger.kernel.org>,
andrea@suse.de, gh@us.ibm.com
Subject: Re: Analysis for Linux-2.5 fix/improve get_pid(), comparing various approaches
Date: Fri, 9 Aug 2002 17:36:15 +0200 [thread overview]
Message-ID: <20020809153615.GA1062@win.tue.nl> (raw)
In-Reply-To: <200208090722.08223.frankeh@watson.ibm.com>
On Fri, Aug 09, 2002 at 07:22:08AM -0400, Hubertus Franke wrote:
> Particulary for large number of tasks, this can lead to frequent exercise of
> the repeat resulting in a O(N^2) algorithm. We call this : <algo-0>.
Your math is flawed. The O(N^2) happens only when the name space for pid's
has the same order of magnitude as the number N of processes.
Now consider N=100000 with 31-bit name space. In a series of
2.10^9 forks you have to do the loop fewer than N times and
N^2 / 2.10^9 = 5. You see that on average for each fork there
are 5 comparisons.
For N=1000000 you rearrange the task list as I described yesterday
so that each loop takes time sqrt(N), and altogether N.sqrt(N)
comparisons are needed in a series of 2.10^9 forks.
That is 0.5 comparisons per fork.
You see that thanks to the large pid space things get really
efficient. Ugly constructions are only needed when a large fraction
of all possible pids is actually in use, or when you need hard
real time guarantees.
Andries
next prev parent reply other threads:[~2002-08-09 15:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-07 22:03 [PATCH] Linux-2.5 fix/improve get_pid() Paul Larson
2002-08-07 23:06 ` Andrew Morton
2002-08-08 0:24 ` Andries Brouwer
2002-08-08 19:42 ` William Lee Irwin III
2002-08-08 20:47 ` Andries Brouwer
2002-08-09 11:22 ` Analysis for Linux-2.5 fix/improve get_pid(), comparing various approaches Hubertus Franke
2002-08-09 15:36 ` Andries Brouwer [this message]
2002-08-09 18:14 ` Hubertus Franke
2002-08-09 16:05 ` Linus Torvalds
2002-08-09 18:18 ` Hubertus Franke
2002-08-08 20:24 ` [PATCH] Linux-2.5 fix/improve get_pid() Linus Torvalds
2002-08-08 21:30 ` H. Peter Anvin
2002-08-08 21:45 ` William Lee Irwin III
2002-08-09 4:42 ` William Lee Irwin III
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=20020809153615.GA1062@win.tue.nl \
--to=aebr@win.tue.nl \
--cc=akpm@zip.com.au \
--cc=andrea@suse.de \
--cc=frankeh@watson.ibm.com \
--cc=gh@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=plars@austin.ibm.com \
--cc=torvalds@transmeta.com \
/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