public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: davids@webmaster.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: epoll,threading
Date: Wed, 30 May 2007 04:35:56 +0900	[thread overview]
Message-ID: <465C809C.60507@gmail.com> (raw)
In-Reply-To: <MDEHLPKNGKAHNMBLJOLKGEJIEBAC.davids@webmaster.com>

David Schwartz wrote:
>> I want to know in detail about , what the events (epoll or /dev/poll or
>> select ) achieve in contrast to  thread per client.
>>
>> i can have a thread per client and use send and recv system call directly
>> right? Why do i go for these event mechanisms?
>>
>> Please help me to understand this.
> 
> Aside from the obvious, consider a server that needs to do a little bit of
> work on each of 1,000 clients on a single CPU system. With a
> thread-per-client approach, 1,000 context switches will be needed. With an
> epoll thread pool approach, none are needed and five or six are typical.
> 
> Both get you the major advantages of threading. You can take full advantage
> of multiple CPUs. You can write code that blocks occasionally without
> bringing the whole server down. A page fault doesn't stall your whole
> server.

It all depends on the workload but thread switching overhead can be
negligible - after all all it does is entering kernel, schedule, swap
processor context and return.  Maybe using separate stack has minor
impact on cache hit ratio.  You need benchmark numbers to claim one way
or the other.

In my experience with web caches, epoll or similar for idle clients and
thread per active client scaled and performed pretty well - it needed
more memory but the performance wasn't worse than asynchronous design
and doing complex server in async model is a lot of pain.

-- 
tejun


  reply	other threads:[~2007-05-30  6:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-26 12:27 epoll,threading Arunachalam
2007-05-26 13:15 ` epoll,threading Ingo Oeser
2007-05-26 23:01 ` epoll,threading David Schwartz
2007-05-29 19:35   ` Tejun Heo [this message]
2007-05-30  7:25     ` epoll,threading Willy Tarreau
2007-05-30  7:50       ` epoll,threading David Schwartz
2007-05-30  8:07       ` epoll,threading David Schwartz
2007-05-30  8:12         ` Change IP TOS inside ethernet driver gshan
2007-05-30 12:58         ` epoll,threading Willy Tarreau
2007-05-30 10:12       ` epoll,threading Tejun Heo
2007-05-30 13:12         ` epoll,threading Willy Tarreau
2007-05-30 13:42           ` epoll,threading Tejun Heo

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=465C809C.60507@gmail.com \
    --to=htejun@gmail.com \
    --cc=davids@webmaster.com \
    --cc=linux-kernel@vger.kernel.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