* Geoff Talvola <[EMAIL PROTECTED]> [010604 20:02]:
> At 09:36 PM 6/3/01 -0400, Jay Love wrote:
> 
> >We talked about this a while back, and I thought the conclusion was to do 
> >it.  It's not very complex, anyway.  But let's revive the debate....
> 
> Last time we went around on this issue, I argued that you're better off 
> preallocating all needed threads up front.  At least on Windows NT, the 
> overhead of a thread that's merely blocking on a Python Queue is basically 
> nil.  Other OS's may have worse thread implementations though -- for all of 
> NT's faults, it seems that threading is one thing it gets right.

Under Linux threads are lightweight in the sense that there is hardly
any work done to create one, Linux uses copy-on-write mechanism so that
only changed pages are copied and only when needed.

That said, it still is a small problem to start of a number of initial
threads upon startup and reuse them when needed.

Probably the best thing is to get this configured by using some form of
a thread allocator class, implement two versions, one that starts
everything on the start and one that changes the number of threads
dynamically.

You have cases for both, the first fits a site with either low traffic
or mostly a constant traffic, the second fits a site that sees large
traffic over a short period of time (Consider the Slashdot Effect).

> I also argued that we'd be better off storing the threads on a stack 
> instead of a queue.  That way the most recently used threads get reused, 
> which may produce slightly better performance.  I wonder if there's a 
> thread-safe Stack class analogous to the Queue class that comes with Python?

That's most probably a good idea.

-- 
Baruch Even
http://baruch.ev-en.org/

_______________________________________________
Webware-devel mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-devel

Reply via email to