- Most treaded code can be converted to an event loop (+async I/O) without issue. Esp if we have co-routines.
- For the other stuff, we'd still have Type 2 threads, which gets the job done.
(Just got back from vacation and was reviewing this aging thread...)
Not to throw a damper on the events party or anything, but an event-based system with asynchronous I/O isn't capable of saturating an SMP box's processors. This is one of the major reasons for using threads in web servers. It's also a significant reason for using threads in desktop applications. Yes, N interpreters for N processors will get you there, but at the cost of times-N static memory consumption (for JITted code, type registries, vtables, etc.: interpreter overhead), and at the cost of fine-grained, lightweight inter-thread communication between the segregated threads.
Further, threading implemented as context switches at block time amounts to a cooperative multithreading environment. Yes, it may provide near-optimal throughput. Despite that, it also has some very bad indeed worst-case latency characteristics. If a worker thread fails to block, the thread which started it will never (or rarely) run and the program will become unresponsive. This makes such a threading model unsuitable for use as in a web application host. One misbehaving HTTP request handler mustn't block other requests. A worker thread mustn't block the UI thread.
Sidenote: Shades of System 7: CPU benchmarks on the old Mac OS do run several percentage points faster than on preemptive systems. The preemptive model is clearly superior in the general case, though; its perceived performance under load is by far superior. Also worth noting: parrot will already be paying the preemptive performance penalty on any modern OS.
I can only hail core events and asynchronous I/O as great advances in parrot. But they are not a general replacement for preemptive multithreading. Of course, TMTOWTDI and YMMV, but parrot should support both models well, and the above line of thought isn't doing threading justice in my opinion.
—
Gordon Henriksen [EMAIL PROTECTED]