http://www.perlmonks.org?node_id=636466


in reply to Re: Slow evolution of Perl = Perl is a closed Word
in thread Slow evolution of Perl = Perl is a closed Word

"Multi-threading is being worked"

Is in working progress for years! How many years we will need to wait to have a good multi-threading model on Perl? I just have waited to much!

  • Comment on Re^2: Slow evolution of Perl = Perl is a closed Word

Replies are listed 'Best First'.
Re^3: Slow evolution of Perl = Perl is a closed Word
by erroneousBollock (Curate) on Sep 01, 2007 at 04:09 UTC
    Is in working progress for years! How many years we will need to wait to have a good multi-threading model on Perl? I just have waited to much!
    I won't pretend that support for robust threading is well implemented in perl5... it's just not.

    However, Java's concurrency is not exactly all that.

    I'd say that Java's concurrency primitives (and the design patterns programmers build on them) are the state-of-the-art circa 1997.

    There are wonderful new ways to think about (and express in code) concurrency that are only really supported well by languages like Erlang, Haskell and Scheme (please let's not have an argument about Scheme). Java's concurrency primitives are concise, robust and orthogonal for the Java language but do not necessarily map well to languages with (encouraged) abstraction techniques based around closures and/or first-class functions.

    I (and many others) agree that perl5's support for threading needs serious work (looks like progress in Parrot/Pugs is good in that area) and that increasingly, folks will focus on concurrency as a dealbreaker, what with 4, 8 and more cores becoming the norm any-time-now.

    If you're concerned about writing good, concurrent, perl5 code today, you might try designing your code around message-passing (look at Thread::Queue) as in Erlang, as this works well in practice.

    -David

Re^3: Slow evolution of Perl = Perl is a closed Word
by chromatic (Archbishop) on Sep 01, 2007 at 06:28 UTC
    How many years we will need to wait...

    I suppose that depends on how many more years you're willing not to contribute somehow to getting a good multi-threading model in Perl. Things don't get done unless someone does them. Sometimes that means people that want them have to take some initiative in getting them done.

      I suppose that depends on how many more years you're willing not to contribute somehow to getting a good multi-threading model in Perl.

      The first step in achieving a good threading model is understanding the limitations of the existing one.

      And the first few steps in doing that is realising that:

      1. the pthreads api has its own set of limitations and is far too low-level to use as the basis for threading in a HLL.
      2. fork is a piss poor model for threading.
      3. Copy On Write (COW) has little or no benefit when the C-level data structures representing Perl-level read-only variables are themselves routinely, internally mutated.
      4. for threading to be fully effective in a high level language, you need both kernel-space (pre-emptive) threading and user-space (cooperative) threading.
      5. Software Transaction Memory (STM) only works for undoable (re-startable) operations.

        If STM is the only state-sharing mechanism, then a very high proportion of the situations and algorithms that most benefit from threading can no longer be coded!

        • You can't undo changes to the file-system, so copy, move, rename, delete etc.

          Whilst it is conceivable to wrap these FS primitives such that they might be undone if the STM requires rollback, other processes may have noticed and acted upon the changes

        • You might attempt buffering reads and writes to files internally, until the STM commits?
        • What do you do for pipe and socket operations?

        STM promises an efficient solution to shared-state memory operations which can benefit some classes of algorithm (the kinds of things PDL does for instance), but it holds little promise for a huge range of other threading scenarios.

      Did you ever visit one of those Echo Canyons, yell, and wonder if anyone is listening?

      Did you ever stick your head into a lion's cage to try and pursuade it to become a vegetarian?


      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.
        Did you ever visit one of those Echo Canyons, yell, and wonder if anyone is listening?

        Funny; as I type this, I'm running Parrot's language tests just before a checkin of working code. Now it's not threading code per se, but it's working code.

      I disagree , some people don't have nearly enough knowledge to implement threads into Perl , telling anyone who wants threads that they should simply implement them is rather dangerous and possibly disastrous(considering that person may not be an expert on the subject , and maybe some people want to write industrial-strength code using Perl threads and don't need amateurish implementations of them ).

      From another point of view , many people just want to use threads , they don't need to implement them for that , they just want to USE them. It's a basic language feature for any decent language ( yes we're in 2009 ) and it's only normal to expect that Perl should have them . It seems most of the times , this is countered by an argument of the form "you don't really need threads, use POE" , which is ok , but that was not was asked in the first place .