[Chicago-talk] threading Question

Jonathan Rockway jon-chicagotalk at jrock.us
Fri Jan 29 22:52:22 PST 2010


* On Wed, Jan 27 2010, packet wrote:

> So your saying i won't have a prob programming on one cpu.And i want
> to know what i can do in perl with a one cpu.I don't want to slow down
> my compile time.

I have a 4 core machine.  With one core, the Moose test suite runs in
about a minute.  With 8 threads (4 + HT), it runs in 7 seconds.

CPAN installs happen before I am done pressing enter.

Modern hardware is really quite nice for your productivity.

To reply to some of the other commentary on this thread; Perl only has
one real threading library - Coro, and it can only use one OS thread
(but happily scales to a 100000 Coro threads).  It's good for IO-intense
activities; if you are a large company's IMAP server, it's likely that
you have a few thousands connections open for "push email".  Most of the
time, the sockets are idle, and so one OS thread is easily enough
compute power for the application.  The hard part is keeping the state
of 10,000+ TCP connections; that's what Coro does for you.  You create a
thread when someone connects, and then that thread "runs" when
necessary.  When it's blocked on IO (99.99% of the time), the other
threads run.

Finally, Perl's ithreads are a not-so-hilarious joke; never use them.

If you need your Perl programs to run in parallel, just split your data
into n sets and run n processes.  Easy.  (And if your Perl is slow,
realize that making it run on 2 cores makes it MAYBE 2x faster at best,
but rewriting the critical sections in a faster language like Haskell
can make it run 50x faster.)

Regards,
Jonathan Rockway

--
print just => another => perl => hacker => if $,=$"


More information about the Chicago-talk mailing list