caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chet Murthy <murthy.chet@gmail.com>
To: caml-list@inria.fr, Tom Ridge <tom.j.ridge+caml@googlemail.com>
Cc: Yaron Minsky <yminsky@janestreet.com>
Subject: Re: [Caml-list] Thread behaviour
Date: Sun, 29 Sep 2013 09:46:35 -0700	[thread overview]
Message-ID: <23010395.NVkQDdK53E@groupon> (raw)
In-Reply-To: <CABooLwOD2zHpL8qgqH5D-6s+j4LEHma2KPXH00A+m9z5r_WCAw@mail.gmail.com>


> OK, but this means that I can't think of OCaml code running in
> different threads in a simple way - I have to consider the single
> runtime lock at least (if I care about performance). So maybe the
> question is: how should I understand the functioning of the single
> runtime lock? For example, is starvation the only thing I need to
> think about?

Tom,

Yaron's note made a careful distinction between two things:
"concurrency" and "performance".  Let me explain a little more what
he's getting at.

"concurrency" means writing programs using constructs that look like
concurrent execution, for the purpose of .... well, for whatever
purpose you'd like, but usually modularity.

  --> in short, you don't care if your code's running on a single
      processor -- you just want to -write- it with multiple threads

  [of course, here you care about -starvation-, hence the worry about
  a tight loop with no possibility of suspension/"releasing the global
  lock"; but let's set that aside, since it's a different concern
  (even the LISPm, from what I remember, had issues here -- heck, so
  do some JVMs, for GC)]

"parallelism" means exploiting hardware facilities to -run- code in
parallel, usually for purposes of performance.

  --> you care very much if your code "properly" exploits
      SMP/multicore parallelism

When you speak of "performance", I'm going to guess that you're really
speaking of "parallelism" and not "concurrency".  If so, Ocaml's
threads are not for you, nor are monadic programming constructs.  Not
merely effectively, but -by- -construction- any threading system with
a global lock can only use a single CPU.  You can get more than that
from Ocaml, if Ocaml threads, spend a lot of time in C/C++ code that's
CPU-intensive.  But I'm assuming that that's not what you're looking
to do.

Does this help?
--chet--


  reply	other threads:[~2013-09-29 16:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27 10:10 Tom Ridge
2013-09-27 10:22 ` Simon Cruanes
2013-09-27 10:27 ` Romain Bardou
2013-09-27 10:51   ` Benedikt Grundmann
2013-09-28 19:09     ` Tom Ridge
2013-09-29  7:54       ` Tom Ridge
2013-09-29 12:37         ` Yaron Minsky
2013-09-29 16:25           ` Tom Ridge
2013-09-29 16:46             ` Chet Murthy [this message]
2013-09-29 17:18               ` Tom Ridge
2013-09-29 17:47                 ` Chet Murthy
2013-09-30  8:24                   ` Romain Bardou
2013-10-07 14:57                     ` Goswin von Brederlow
2013-09-30  8:16       ` Romain Bardou
2013-10-01  3:32         ` Ivan Gotovchits
2013-10-07 14:49       ` Goswin von Brederlow
2013-09-30  9:18 ` Xavier Leroy
2013-09-30 15:12   ` Tom Ridge
2013-09-30 16:01     ` Török Edwin
2013-09-30 16:56     ` Gabriel Kerneis
2013-09-30 18:18       ` Alain Frisch
2013-10-01  5:01   ` Pierre Chambart
2013-10-01  7:21     ` Gabriel Kerneis
2013-10-02 10:37     ` Wojciech Meyer
2013-10-02 11:52       ` Francois Berenger
2013-10-02 11:58         ` Wojciech Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23010395.NVkQDdK53E@groupon \
    --to=murthy.chet@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=tom.j.ridge+caml@googlemail.com \
    --cc=yminsky@janestreet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).