Re: Many threads in Linux
- From: Dmitriy Vyukov <dvyukov@xxxxxxxxx>
- Date: Sun, 16 Dec 2007 01:53:39 -0800 (PST)
On Dec 16, 11:50 am, llothar <llot...@xxxxxx> wrote:
My goal was to measure the overhead of using threads, so the server
does the minimum possible that lets me verify that it's basically
working. And at any rate, my real request handling involves only
parsing a line of text then sending a message to a message queue, so
it's fairly comparable.
Okay i see.
This seems to work as long as you can do the parsing and queuing in
one
time slice. So that there are only ready or idle tasks but the work of
a thread
will never be delayed by serving 100000 other threads first until it
can do some
work again. This might work well because it is a very very simple
server.
Good point. If request processing involves some system calls or memory
allocation or enqueueing into some queue protected by mutex, worker
thread can be blocked inside request processing, and things can get
bad.
Scott, you can try to insert something like this into request
processing:
// sleep 1 ms with 10% probability
if (0 == (rand() % 10)) sleep(1);
Dmitriy V'jukov
.
- Follow-Ups:
- Re: Many threads in Linux
- From: David Schwartz
- Re: Many threads in Linux
- From: Scott Gifford
- Re: Many threads in Linux
- References:
- Many threads in Linux
- From: Scott Gifford
- Re: Many threads in Linux
- From: David Schwartz
- Re: Many threads in Linux
- From: Scott Gifford
- Re: Many threads in Linux
- From: Marcel Müller
- Re: Many threads in Linux
- From: Scott Gifford
- Re: Many threads in Linux
- From: Eric Sosman
- Re: Many threads in Linux
- From: Scott Gifford
- Re: Many threads in Linux
- From: Scott Gifford
- Re: Many threads in Linux
- From: Scott Gifford
- Re: Many threads in Linux
- From: llothar
- Re: Many threads in Linux
- From: Scott Gifford
- Re: Many threads in Linux
- From: llothar
- Many threads in Linux
- Prev by Date: Re: Many threads in Linux
- Next by Date: Re: memory visibility and signals...
- Previous by thread: Re: Many threads in Linux
- Next by thread: Re: Many threads in Linux
- Index(es):
Relevant Pages
|