Python Performance vs. C++ in a Complex System

Courageous jkraska1 at san.rr.com
Mon Apr 16 19:57:53 EDT 2001


On Mon, 16 Apr 2001 16:43:42 GMT, ben at co.and.co wrote:

>Aahz Maruch <aahz at panix.com> wrote:
> 
>> I'm 99% certain the original poster is using microthreads, which
>> essentially implements what you're talking about.
>
>Not in his C++ implementation. BTW, the scheduler of the OS may be as
>good as it is, but with 15,000 threads and a few CPU's (1??) you're
>going to spend a lot of time in the scheduler anyhow.

You're exactly correct. In C++, I'd be completely toasted if I were using
kernel-level threads. However, I'm not. I'm doing cooperative multithreading
on top of exactly one OS thread. Preemptive multitasking is exactly what I
don't want: this is a simulation where time-slicing across real-time is not meaningful.
It is the coordinated flow of agent-tasks through SIMULATED time which matters.

My cooperative multithreading core is a highly-optimized vector-allocated
priority heap; context-switches are essentially a register save/restore, however
this is accomplished with Microsoft's Fiber interface, which allows me to avoid
assembly. My prior limit here is the minimum 1 page (64K) commit of virtual
memory per thread; with a user-addressable virtual memory under 2K/NT
of 2 gigs, the C++ system drops dead at just over 31,000 threads.

The Python implementation can handle considerably more, and it's largely
dependent on real memory only (no virtual limit). This is because Stackless
has only one real stack (in the interpreter).



C//




More information about the Python-list mailing list