in reply to Re^9: OT: Locking and syncing mechanisms available on *nix.
in thread OT: Locking and syncing mechanisms available on *nix.

Thanks. I'll take a look at glibc. Any feel for how widely available it is across *nixes?

If thread-switching performance is really critical, and pthreads are too slow,

You've got the wrong end of the stick. It isn't the pthreads or threads that are too slow, it is threads::shared.

Vis. Using Thread::Queue (which uses threads::shared and its cond vars and mutexes), the best throughput I've achieved between two threads is about 50,000 scalars/second.

My current implementation is achieving (on Windows using event objects) 500,000 scalars/second reliably, and I've seen close to twice that.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^10: OT: Locking and syncing mechanisms available on *nix.

Replies are listed 'Best First'.
Re^11: OT: Locking and syncing mechanisms available on *nix.
by educated_foo (Vicar) on Mar 27, 2011 at 21:29 UTC
    Hopefully we're on the same page now, though I'm getting well outside my area of personal experience (I've done threaded programming, but avoid it like the plague in Perl). IIUC switching between Perl interpreter contexts is painfully expensive, and since each queue message requires 3 switches (wait/signal/wake), that can crush you.

    I haven't used them before, but isn't this a good place to apply Coro and/or Coro::EV? The Coro docs even say:

    Benchmarks using i-threads which are communication-intensive show extremely bad behaviour with i-threads (in fact, so bad that Coro, which cannot take direct advantage of multiple CPUs, is often orders of magnitude faster because it shares data using real threads, refer to my talk for details).
      isn't this a good place to apply Coro

      No. It would completely defeat the purpose of the threading, which is to spread the cpu load of a process across multiple cores. Coro does not (can not) utilise multiple cores or processors.

      The Coro docs even say

      Unfortunately, the Coro docs are little more that a work of unimaginative fiction. They render some very clever code and coding--when used for appropriate purposes--almost valueless due to the asinine headline claim; knowingly, utterly biased and useless benchmark; and a complete misunderstanding or misrepresentation of ithreads.

      For my purpose, they are entirely inappropriate.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.