Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Out of curiosity does Perl threads work the same as Python and it's GIL? With python to get the benefit of multithreading and utilize all cores for CPU intensive tasks you have to use multiprocessing.</p> </blockquote> <p>No, but the conclusion is the same. Perl <em>doesn't</em> have a big lock protecting the interpreter across threads; instead it has a <em>duplicate interpreter</em> for each different thread. Since a variable belongs to an interpreter (and only one interpreter), no data is shared by default between threads. When variables are explicitly shared they're placed in a shared interpreter which serializes all accesses to shared variables on behalf of the other threads. In addition to the memory issues mentioned by others here, there are also some serious performance issues with threads in Perl, as well as limitations on the kind of data that can be shared and what you can do with it (see <a href="http://p3rl.org/perlthrtut">perlthrtut</a> for more info).</p> <p>The upshot is, if you need to parallelize a lot of IO and you can make it non-blocking, you'll get a lot more performance out of an event loop model than threads. If you need to parallelize stuff that <em>can't</em> be made non-blocking, you'll probably have a lot more luck with multi-process than with perl threads (and once you're familiar with that kind of code, it's also easier to debug).</p> <p>It's also possible to combine the two models (for example, a mostly-single-process evented app that passes off certain expensive work to child processes using <a href="http://p3rl.org/POE%3a%3aWheel%3a%3aRun">POE::Wheel::Run</a> or <a href="http://p3rl.org/AnyEvent%3a%3aRun">AnyEvent::Run</a>, or a multi-process app that has an evented parent managing non-evented children, or a Node Cluster type setup where you have a number of preforked evented webservers, with a parent that just <code>accept</code>s and passes FDs to its children).</p> <p>There's no silver bullets, though, at least not yet.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload