Re: Global data concurrent access ?
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Sat, 6 Jan 2007 21:08:51 -0000
Chris Mullins [MVP] <cmullins@xxxxxxxxx> wrote:
"Kunal" <koolkunal@xxxxxxxxx> wrote
There are about 10 new threads created per second. Threads do some
processing and die. All threads process based on data read from the
global structure.
You want to abandon this architecture as quickly as you can. The cost of
creating and destroying threads is very high, and at 10 threads per second,
you're application is spending 95% of it's time creating threads, and 5%
doing the work you want done.
While I agree that creating a lot of threads is reasonably expensive, I
don't think it's quite as bad as all that.
On my laptop, creating and starting 500 threads takes about 120-170ms.
(I haven't got the energy to work up a good benchmark - this is about
as crude as they come.)
Assuming linear scaling (and it should actually be better than that,
because with only 10 threads at a time there'll be less context
switching) that would suggest that 10 threads would take less than 4ms
to start - i.e. under 1% of the time. Yes, it's a very crude benchmark
- but I do think 95% is higher than reality.
Just to reiterate though, I totally agree that the OP should move away
from that architecture ASAP :)
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: Global data concurrent access ?
- From: Chris Mullins [MVP]
- Re: Global data concurrent access ?
- References:
- Global data concurrent access ?
- From: Kunal
- Re: Global data concurrent access ?
- From: Chris Mullins [MVP]
- Global data concurrent access ?
- Prev by Date: ClickOnce
- Next by Date: Re: Global data concurrent access ?
- Previous by thread: Re: Global data concurrent access ?
- Next by thread: Re: Global data concurrent access ?
- Index(es):
Relevant Pages
|