MCE is cool, but just adds a convenient communication layer to adult child OS perl processes spawned via fork. If you want real OS threads (what most of the non-Perl world considers threads), you'll need to look at something like Inline::C + OpenMP + Alien::OpenMP or PDL::ParallelCPU (pthreads).

Given what I consider the semantics of map, you may also think about looking at Parallel::ForkManager::Segmented which gives some convenient sugar for chunking up work among child processes (on top of the awesome Parallel::ForkManager - and I think will reuse them without unduly aborting them prematurely (thus saving the overhead of spawning new processes) - and if doesn't maintain an actual pool, you're at lease amortizing the start up time over multiple items processed rather than one new process per item.

> I tried it with various versions of perl (5.16, 5.24, 5.32 and 5.34) and I get similar results

This is because you're likely testing on the same hardware and OS, which means same forking overhead. It's not rocket surgery.


In reply to Re: I thought MCE::Map is faster than usual map. What am I missing? by perlfan
in thread I thought MCE::Map is faster than usual map. What am I missing? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.