4 ms·
I'll admit to being a major Perl hater. However, this Coro library looks great! Perl threads are horrible pieces of trash, and the Coro library author not only
by sreque 17y ago
I'll admit to being a major Perl hater. However, this Coro library looks great! Perl threads are horrible pieces of trash, and the Coro library author not only admits this but does something about it by implementing threads the way nature intended them to be. If I'm ever forced to code in Perl again and need or want threads, I will turn to this library first.
The way the Coro author implements Perl threads, by the way, sounds similar to how MacRuby and Rubinius are attempting to remove the GIL in ruby by copying interpreter state so that multiple OS threads can run simultaneously.
edit: after reading further, it turns out these threads are cooperative in that only one can run at a time. Also, it looks like they act more like Ruby fibers in that one must give up control explicitly or make a blocking call that implicitly gives up control. I'd rather the core scheduler be able to preempt threads directly. What if one of the threads takes a long time or ends up in an infinite loop?
"This module collection manages continuations in general, most often in the form of cooperative threads (also called coros, or simply "coro" in the documentation). They are similar to kernel threads but don't (in general) run in parallel at the same time even on SMP machines"
- jrockway 17y agoThey can be automatically preempted if you desire, see: http://github.com/nothingmuch/coro/commit/54902809d8d3ad054d75a0d8b7ed58df5c20127c http://github.com/nothingmuch/coro/commit/54902809d8d3ad054d... Usually people dismiss Coro because they want to take advantage of multiple cores without running multiple processes. But the reality is that you'll see a maximum 8x speedup if you run 8 OS threads, but if you rewrite your critical section in Haskell, you'll see a 50x speedup. So really , Coros are exactly the right abstraction for "scripting languages". IO performance is great, and expressiveness is great. Speed can be gained in other ways.
- sreque 17y agoI agree entirely about not needing threads in a scripting language like perl for CPU performance reasons, and being able to configure the threads to be scheduled automatically is a big win in my book. Thanks for letting me know about the library!
- deleted 17y ago[deleted]
- deleted 17y ago[deleted]