caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Richard Jones <rich@annexia.org>
Cc: Nathaniel Gray <n8gray@gmail.com>,
	Bardur Arantsson <spam@scientician.net>,
	caml-list@inria.fr
Subject: Re: [Caml-list] Re: Help interfacing with C
Date: Sat, 19 Aug 2006 19:41:51 +1000	[thread overview]
Message-ID: <1155980511.29567.24.camel@rosella.wigram> (raw)
In-Reply-To: <20060819090319.GA2213@furbychan.cocan.org>

On Sat, 2006-08-19 at 10:03 +0100, Richard Jones wrote:

> It sounds also like you shouldn't use select at all, but consider some
> of the more modern alternatives.  Here is a good place to start:
> 
> http://www.kegel.com/c10k.html#nb.select

Yeah but if you were doing that you'd probably want 
to use the demux library which is part of Felix ..
in which case you'd want to use it as part of the
context switching too .. in which case you might was
well just use Felix instead of Ocaml :)

I'd be thinking of Equeue if you do want to use 'modern'
alternatives, since it has generic support for 
different notification methods: looks like you could
use a select binding, and switch to some other method
later if you weren't happy with the performance.
Perhaps Gerd can confirm this?

Felix chooses the best of: epoll, kqueue, poll,
windows IOcompletion ports, Solaris iocompletion ports,
and select and abstracts the lot away. The end user
just does blocking I/O .. but it only blocks fibres,
not threads (unless there is nothing ready of course).
[Doesn't the VMthreads of bytecode do this too?]

The difficulty getting this right should not be underestimated.
For example, epoll is available in Linux 2.4 but it doesn't work:
the config script actually has to call it to find out it is
dysfunctional. Felix outperforms C10K by at least 2 decimal
orders of magnitude, without resorting to callbacks, and
without assembler hacks like stack swapping. It does this by
*translating* code using a thread model into code using a
callback model. The demux library demultiplexes notifications
and hooks the results into the scheduling algorithm.

I believe both Haskell and MLton can do this kind of thing
too (though I'm not sure): continuation passing is essential.
I don't think Ocaml uses continuation passing, however most
bytecode interpreters do (including for example Python)
because it's the only way to write a bytecode interpreter :)
Felix uses heaped continuations for procedures, but the
stack for functions.. a fairly novel and rather ugly mix
(required for C compatibility .. and also yielding the best
performance).

All these systems, either implicitly or, now in the case
of Felix quite explicitly .. are replacing poor operating
system designs like Unix. You have to remember Unix was
designed for batch processes with some time sharing:
its hardly surprising it doesn't work well with threads
and real time events .. it was designed to isolate the
end user from these features!

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2006-08-19  9:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-16 19:34 Nathaniel Gray
2006-08-17  3:49 ` [Caml-list] " malc
2006-08-18 21:00   ` Nathaniel Gray
2006-08-17  5:56 ` Bardur Arantsson
2006-08-18  7:10   ` [Caml-list] " Olivier Andrieu
2006-08-18 15:50     ` Bardur Arantsson
2006-08-18 21:33   ` [Caml-list] " Nathaniel Gray
2006-08-18 22:24     ` Bardur Arantsson
2006-08-19  0:33       ` [Caml-list] " Nathaniel Gray
2006-08-19  6:03         ` Bardur Arantsson
2006-08-21 22:45           ` [Caml-list] " Nathaniel Gray
2006-08-19  8:30         ` Olivier Andrieu
2006-08-21 22:35           ` Nathaniel Gray
2006-08-19  9:03     ` Richard Jones
2006-08-19  9:41       ` skaller [this message]
2006-08-18  8:46 ` [Caml-list] " Damien Doligez
2006-08-18 20:09   ` Nathaniel Gray
2006-08-23 23:36 ` Nathaniel Gray

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=1155980511.29567.24.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=n8gray@gmail.com \
    --cc=rich@annexia.org \
    --cc=spam@scientician.net \
    /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).