in reply to Why Coro?

The biggest problem with Coro is the bullshit factor.

Coro - the only real threads in perl

Bullshit! See last element below.

Unlike the so-called "Perl threads" (which are not actually real threads but only the windows process emulation (see section of same name for more details) ported to unix, and as such act as processes)

As is this.

They are "actually real threads". Real, kernel scheduled, core concurrent, execution contexts. (One use of which on Windows, is to emulate fork).

And the segregated address space, despite the limitations, allows Perl threads to avoid the main "problem" with threads in other languages: that of unintentional sharing of thread-scoped data.

A parallel matrix multiplication benchmark runs over 300 times faster on a single core than perl's pseudo-threads on a quad core using all four cores.

As is this.

See Re^6: If I am tied to a db and I join a thread, program chrashes for why the benchmark is a totally broken piece of marketing hype that serves little purpose beyond forwarding an agenda.

In this module, a thread is defined as "callchain + lexical variables + some package variables + C stack),

As is this.

Contrast that definition of "thread" with that from wikipedia: In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system.

My emphasis.

And the first three words do not justify this flagrant mis-definition. It's like calling a stately home (or The Whitehouse) an aeroplane, because they both have wings.

Coro's event's don't scale across cores. And cores are now both ubiquitous; and the only way to maintain Moore's Law going forward.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^2: Why Coro?
by dk (Chaplain) on Jul 28, 2010 at 10:11 UTC
    Not to argue with you point, but I think if the Coro's author had written "fiber" instead of "thread", there would be much less confusion now.

      Yes. That would be a perfect description of Coro's coroutines. Though "coroutines" is better, if for no other reason than it is a term that isn't associated with MS, as fibres (wrongly) are. It's also an older and very well understood term in CS circles.

      But I think that is to ignore the political aspect of the Coro pod. Anyone who includes vitriol like this in a module's documentation, is obviously too far gone for rationality.

      A great many people seem to be confused about ithreads (for example, Chip Salzenberg called me unintelligent, incapable, stupid and gullible, while in the same mail making rather confused statements about perl ithreads (for example, that memory or files would be shared), showing his lack of understanding of this area - if it is hard to understand for Chip, it is probably not obvious to everybody).

      Especially as what Chip Salzenberg said is correct. At least as far as memory and file handles are concerned; they are shared within a single process space. Access is controlled and limited only at the language level; not the kernel or processor level. As for his remarks about the author, I don't know him so I couldn't make comment; but I suspect that anyone with even a cursory understanding of ithreads has long since drawn their own conclusions.

      The only lack of understanding regarding ithreads is clearly demonstrated by the author. Though I suspect his "confusion" is, at least in part, political rather than genuine.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Anyone who includes vitriol like this in a module's documentation, is obviously too far gone for rationality
        For what it's worth, I found the author to be very much available and helpful for newbie Coro questions on IRC.

        Marc Lehmann is in fact spot on and Chip is incorrect. There's no "politics" involved here. At least not on Marc's side.

        Perl's "threads" are not threads in the generally accepted term, yes wikipedia does say "In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system."

        But it also goes on to say

        ", but in most cases, a thread is contained inside a process."

        Perl's implementation of "threads" is actually done using forking and there is *no* shared memory space. You're getting confused as what actually happens is *ALL* the data from the main process is copied across to the memory space of the "threads". They are processes and have their own memory space. Real threads execute inside the 1 process and share memory.

        For interpreted languages there is what's called a GIL(Global Interpreter Lock) which is there to prevent non-thread safe code being shared with other kernel threads. Ruby and Python have a GIL and their threads are known as 'green threads' which are not kernel level but are after the GIL, but still share memory. They of course will not take advantage of multi-cores. On a side note you can get real kernel level threads with both Ruby and Python through jRuby and jPython, but nothing like that exists for Perl.

        Perl's psuedo-threads will take advantage of multiple-cores because they are processes and they do NOT share memory. Marc knows his stuff. He wouldn't have been able to write Ev, AnyEvent, Coro to be as stable and fast as they are if he was lacking in such basic knowledge that even *I* know and I consider myself intermediate at best.

        But, please don't take my word for it. Check perlthrtut. First paragraph.

        "This tutorial describes the use of Perl interpreter threads (sometimes referred to as ithreads) that was first introduced in Perl 5.6.0. In this model, each thread runs in its own Perl interpreter, and any data sharing between threads must be explicit. The user-level interface for ithreads uses the threads class."

        Notice the word 'explicit'. That means you have to, yourself share any data between 'threads'. This is the very purpose of threads::shared. Why would that module exist if Perl 'threads' shared memory as Chip Salzenberg and yourself claim?

          A reply falls below the community's threshold of quality. You may see it by logging in.