caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Pierre-Evariste Dagand" <pedagand@gmail.com>
To: raould@gmail.com, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: Where's my non-classical shared memory concurrency technology?
Date: Tue, 20 May 2008 02:04:33 +0200	[thread overview]
Message-ID: <6cb897b30805191704q253aae2dq43a6c0dd8ad3d394@mail.gmail.com> (raw)
In-Reply-To: <91a2ba3e0805191537g7fec02f9h7c46aa1be4b92270@mail.gmail.com>

Hi all,

>  i am under the impression that STM is harder to optimize since
>  generally you don't know what the transactions collided on. whereas
>  with a "hot lock" you can see precisely what code uses that lock and
>  what it locks.

I'm not so sure... In fact, my work in the past 4 months has been to
build a toy language to experiment with the Automatic Mutual Exclusion
semantic defined in [1]. At the beginning, I was, just like most of
you, quite sceptical about STM and its performance.

Besides, in this language, *everything* is under a transaction :
unless you specify it explicitly with the keyword "unprotected", every
access to memory is saved in a transaction. This have the nice
property to produce, by default, proven thread-safe code.

But, without transactional processors, this have a high performance
cost, as you can imagine. The second part of my work has been to
develop a kind of profiler that provide the developer with the "hot
transactions". And I have just finished it a minute ago, hence I can
show you a nice, typical output :

Frequency          Definition pos.          Transactions
80.%               88                       { [ 31247 | read ]  } <->
{ [ 31247 | read ] [ 31318 | write ]  }
                                            { [ 31247 | read ]  } <->
{ [ 31247 | read ] [ 31318 | write ]  }
                                            { [ 31247 | read ]  } <->
{ [ 31247 | read ] [ 31318 | write ]  }
                                            { [ 31247 | read ]  } <->
{ [ 31247 | read ] [ 31318 | write ]  }
20.%               49                       { [ 31425 | read ]  } <->
{ [ 31425 | read ] [ 31450 | write ]  }

Therefore, you first develop your code, with everything in a
transaction. Then, you run the profiler. Here, you see that the
reference cell defined at character 88 of the source code is a the
root of 80% of the conflicts. And you know the conflicting
transactions. At that point, you can either change the code to get
less contention of this reference cell (my choice here) or shorten the
transactions by, explicitly, committing them more frequently.

( this profiles my implementation of a concurrent Queue and the cell
at char 88 contains the size of the queue that is
incremented/decremented when we push/pop )

Hence, concerning performance, you will be able to, easily, identify
"hot transactions" and reduce the number of conflicts. But I see
someone in the room arguing that he don't even want to bother with
transactions because there is a 4242% decrease in speed. Good news !
With the "unprotected" keyword, you can work out of any transactions,
at full speed, *without sacrificing thread-safety* (and this is
ensured by the type-system).

To sum up, the idea is "thread-safe by default" and then "earn more
(speedup) by working more". Some people has been elected with such
ideas, I might get the Turing award for that...

If someone is interested in this toy language, let me know. But the
great and crazy part now is to transfer this technology in OCaml. For
the programmer, that's just 3 new keywords in the language. For the
guy that will implement AME in OCaml, well... that's a lot of work...

Regards,


[1]: http://research.microsoft.com/~tharris/papers/2008-popl.pdf

-- 
Pierre-Evariste DAGAND
http://perso.eleves.bretagne.ens-cachan.fr/~dagand/


  reply	other threads:[~2008-05-20  0:04 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-18  8:39 Berke Durak
2008-05-18 16:35 ` Jon Harrop
2008-05-19 11:45   ` [Caml-list] " Martin Berger
2008-05-19 12:24     ` Berke Durak
2008-05-19 21:47       ` Jon Harrop
2008-05-19 22:24         ` Berke Durak
2008-05-19 22:37           ` Raoul Duke
2008-05-20  0:04             ` Pierre-Evariste Dagand [this message]
2008-05-20 21:27           ` David Teller
2008-05-21  7:52             ` Martin Berger
2008-05-21  8:06       ` Martin Berger
2008-05-19 14:09     ` Gerd Stolpmann
2008-05-19 16:30       ` Richard Jones
2008-05-19 18:26       ` Jon Harrop
2008-05-20  7:40       ` Ulf Wiger (TN/EAB)
2008-05-21  8:18         ` Martin Berger
2008-05-21  8:06       ` Martin Berger
2008-05-21 13:50         ` Gerd Stolpmann
2008-05-26 15:29         ` Damien Doligez
2008-05-26 16:08           ` Jon Harrop
2008-05-27  9:34           ` Martin Berger
2008-05-28 11:18             ` Damien Doligez
2008-05-28 12:16               ` Jon Harrop
2008-05-28 17:41               ` Martin Berger
2008-05-29 12:02               ` Frédéric Gava

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=6cb897b30805191704q253aae2dq43a6c0dd8ad3d394@mail.gmail.com \
    --to=pedagand@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=raould@gmail.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).