RE: Why use threads ( was: Alan Cox quote?)

Davide Libenzi (davidel@xmailserver.org)
Thu, 21 Jun 2001 09:10:50 -0700 (PDT)


On 21-Jun-2001 David Schwartz wrote:
> Okay, let's compare two servers.
>
> Server one is handling 10 file descriptors. The cost of a single call to
> poll is 3 microseconds. Assume that the server is coded to get back to
> 'poll' as quickly as it can, but due to load the code manages to call 'poll'
> every 100 microseconds, so the overhead of poll is 3% of the available CPU.

Maybe You read a paper by Richard Gooch but I think You read it wrong :

http://www.atnf.csiro.au/~rgooch/linux/docs/io-events.html

<quote>
The kernel has to scan your array of FDs and check which ones are active. This
takes approximately 3 microseconds (3 us) per FD on a Pentium 100 running Linux
2.1.x. Now you might think that 3 us is quite fast, but consider if you have an
array of 1000 FDs. This is now 3 milliseconds (3 ms), which is 30% of your
timeslice (each timeslice is 10 ms). If it happens that there is initially no
activity and you specified a timeout, the kernel will have to perform a second
scan after some activity occurs or the syscall times out. Ouch! If you have an
even bigger application (like a large http server), you can easily have 10000
FDs. Scanning times will then take 30 ms, which is three timeslices! This is
just way too much.
</quote>

Anyway there's no need to continue this ( quite long ) thread.

- Davide

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/