Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^12: Amicable divorce

by salva (Canon)
on Jul 24, 2020 at 15:48 UTC ( [id://11119766]=note: print w/replies, xml ) Need Help??


in reply to Re^11: Amicable divorce
in thread Amicable divorce

No amount of syntax will give me SMP-multithreading in Perl

Do you mean perl 5.005 threads?

IIRC, the conclusion we got from there is that it is not doable without rewamping the runtime completely.

Perl internal data structures were never designed for atomic access so locks need to be used to serialize their access. You could do as Python, have a global lock (bye bye SMP!) or require the programmer to lock by hand (that was the 5.005 approach), but that didn't work. Most modules failed to work in multithreading environments, usually because of the perl internals becoming corrupted... XS code was even worse.

Perl 5.6 threads was a compromise where everything is cloned so that there is no interference between threads and whenever you want to share something, you have to say it explicitly and an intermediate (and quite inefficient) layer that does the locking and serializes access is set up by the runtime.

So, in conclusion, do you want SMP in Perl 5? then write a new runtime! and forget about compatibility with any XS module!!!

Would it be worth the trouble? IMO, well, maybe yes. There are so many things in Perl 5 that need fixing that could only be fixed by using a new runtime!!!

But anyway, who is gonna do it?

Update: oops, s/5\.6/5.005/g; s/5\.8/5.6/g;. I knew I had it wrong because I can still remember my excitment trying the threads support with LWP and getting SIGSEGVs all the time when perl 5.005 was released 22 years and two days ago! Just one of those things than randomly stick in your mind!

Replies are listed 'Best First'.
Re^13: Amicable divorce
by LanX (Saint) on Jul 24, 2020 at 16:00 UTC
    > Perl 5.8 threads was a compromise where everything is cloned so that there is no interference between threads and whenever you want to share something, you have to say it explicitly and an intermediate (and quite inefficient) layer that does the locking and serializes access is set up by the runtime.

    I'm by far no expert here, but I remember seeing benchmarks where the Perl approach actually did beat Python's GIL in terms of performance.

    But benchmarks are like statistics, the author often only measures his own prejudices ... ;-)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      I'm by far no expert here, but I remember seeing benchmarks where the Perl approach actually did beat Python's GIL in terms of performance.

      Different trade-offs: Python thread creation is cheap, but then they don't run in parallel except when performing I/O operations. Data is shared and there is no overhead for using threads.

      Perl on the other hand, has a very costly thread creation, both in terms of CPU and memory. But then they run in parallel using all the available CPUs. Data is only shared between threads when explicitly requested by the programmer and accessing the shared data has an important overhead.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119766]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-03-29 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found