caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chet Murthy <chet@watson.ibm.com>
To: Dave Berry <dave@kal.com>
Cc: Chet Murthy <chet@watson.ibm.com>,
	STARYNKEVITCH Basile <Basile.Starynkevitch@cea.fr>,
	caml-list@inria.fr
Subject: Re: callcc/cps-style programming
Date: Wed, 13 Dec 2000 11:36:55 -0500	[thread overview]
Message-ID: <200012131636.LAA02306@bismarck-chet.watson.ibm.com> (raw)
In-Reply-To: Your message of "Wed, 13 Dec 2000 13:44:20 GMT." <3145774E67D8D111BE6E00C0DF418B6638D1D3@nt.kal.com>


Dave,

I forget the reference -- I myself only saw it on the Web a few years
back, but I'm sure that if you find Ousterhout's publications, it
should be there.  In addition, it was (one of) the cause(s) of
Stallman's Great Anti-TCL Rant.  Not that I'm a fan of TCL.  Just
that, well, I have to give Ousterhout his props.  I give Stallman his
props, too, of course.

I do understand and agree that, often lightweight threads make certain
types of I/O-intensive applications easier to write.  But the come at
a considerable cost, which is in two forms -- performance and code
quality.

  (a) context-switching becomes expensive -- register-set swaps are
  required

  (b) programmers simply do not know how to write multi-threaded code

I've seen both of these problems in the real world.

It is well-understood at this point that unless you have
compute-intensive tasks, it is _always_ more efficient to use
user-level threads than it is to use kernel threads.  In addition, one
finds that most of the old-line operating systems did explicit
continuation-style suspension.  I.e., events, not kernel threads.
What all this means, is that the more explicitly you can get a handle
on the state that you need for your continuing computation, the more
efficient you can make that suspend/resume.  And that's important in a
server environment.

[My daily work for the past 6 years has been making high-volume
web-application servers work under extreme load conditions for large
enterprise customers.  CPU budgets matter as much as they ever did in
the '70's, if not more.  No reasonable number of extra CPUs from
CompUSA will catch up to a Super Bowl ad.]

Likewise, I've seen enough different examples, both from within the
JDK and from outside of it, of multi-threaded code causing horrors, to
believe that programmers simply don't know how to write it.

Stuff like:

  (i) allocating memory in the middle of a finalizer -- e.g., a
  finalizer which is pushing some reusable resource onto some stack
  (and the stack needs to be grown)

  (ii) locking some object in a finalizer, which can also be locked by
  some thread that which would allocate memory with that lock held.

  (iii) SMP-unsafe code galore -- race conditions, memory-incoherence,
  thrash-prone code.

This is but a short, short list.  What really bothers me about
threading, is that, well, the only good cases where threading is
palatable for vanilla programmers, are those where the threads do not
interact.  And, yeah, sure, that's nice.  But that's a pretty small
subset of the important applications in this world.

Even in transaction-processing, where all transactions are supposed to
be "isolated", that's just the _model_.  Of _course_ transactions
interact, in the way they access shared resources, pooled connections,
caches of precomputed (but slowly invalidated) data, etc.

Conclusion:

I'm not saying that threads are bad.  Rather, what I'm saying is,
there is little need, in a language like CAML, for _user-level_
threads.  Kernel threads, you need, for talking to DB2 or Oracle.
Period.  But user-level threads, implemented in the language, don't
give you much value.  Much better to do some sort of explicit (perhaps
semi-automated) CPS-conversion, and use an event-dispatcher.

Amongst other things, at least, you'll never have to worry about being
time-sliced where you didn't expect it.

--chet--



  reply	other threads:[~2000-12-14 18:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-13 13:44 Dave Berry
2000-12-13 16:36 ` Chet Murthy [this message]
2000-12-14 19:20   ` T. Kurt Bond
2000-12-15 13:31     ` Martin Berger
2000-12-15 18:37   ` Julian Assange
2000-12-15 23:10     ` Chet Murthy
  -- strict thread matches above, loose matches on Subject: below --
2000-12-14 19:08 forsyth
2000-12-06 20:13 Joe Lisp
2000-12-07  8:31 ` STARYNKEVITCH Basile
2000-12-09  3:58   ` eijiro_sumii
2000-12-09 18:48   ` Chet Murthy
2000-12-12 17:14     ` John Max Skaller
2000-12-08 10:50 ` Xavier Leroy

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=200012131636.LAA02306@bismarck-chet.watson.ibm.com \
    --to=chet@watson.ibm.com \
    --cc=Basile.Starynkevitch@cea.fr \
    --cc=caml-list@inria.fr \
    --cc=dave@kal.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).