caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Kuba Ober <ober.14@osu.edu>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: thousands of CPU cores
Date: Thu, 17 Jul 2008 08:48:18 -0400	[thread overview]
Message-ID: <200807170848.18494.ober.14@osu.edu> (raw)
In-Reply-To: <1216145029.16617.42.camel@flake.lan.gerd-stolpmann.de>

On Tuesday 15 July 2008, you wrote:
> Am Dienstag, den 15.07.2008, 11:57 -0400 schrieb Kuba Ober:
> > On Thursday 10 July 2008, Gerd Stolpmann wrote:
> > > Am Donnerstag, den 10.07.2008, 21:02 +0000 schrieb Sylvain Le Gall:
> > > > On 10-07-2008, Gerd Stolpmann <info@gerd-stolpmann.de> wrote:
> > > > > Am Donnerstag, den 10.07.2008, 20:07 +0000 schrieb Sylvain Le Gall:
> > > > >> On 10-07-2008, Gerd Stolpmann <info@gerd-stolpmann.de> wrote:
> > > > >> > In Ocaml you can exploit multi-core currently only by using
> > > > >> > multi-processing parallel programs that communicate over message
> > > > >> > passing (and only on Unix). Actually, it's an excellent language
> > > > >> > for this style.
> > > > >>
> > > > >> Why only on Unix ?
> > > > >
> > > > > No fork() on Windows. And emulating its effects is hard.
> > > >
> > > > open_process + stdin/stdout should do the trick... at least i think
> > > > so.
> > >
> > > After having ported godi to mingw I am not sure whether this works at
> > > all. The point is that you usually want to inherit OS resources to the
> > > child process (e.g. sockets). The CreateProcess Win32 call
> > > (http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx) mentions
> > > that you can inherit handles, but I would be careful with the
> > > information given in MSDN. Often it works only as far as the presented
> > > examples. Windows isn't written for multi-processing, and its syscalls
> > > aren't as orthogonal as in Unix-type systems.
> >
> > Windows syscalls are quite reasonable IMHO, if a tad undocumented.
> > ReactOS folk have done a great job of reimplementing most of them, and
> > there isn't anything mucho broken about those. In fact, I'd posit that
> > Windows native syscalls expose some functionality that's traditionally
> > unavailable on unices and requires hacks to achieve (usually via
> > executable code injection). Just look at what Wine folks had to do in
> > order to emulate some win32 (not even native!) API on Linux: a lot of
> > hard work for what amounts to a single API call. This of course works
> > both ways, and on Windows, while a fork() implementation is simple, it
> > AFAIK requires a custom loader or some other ingenuity to work.
>
> Sure, both systems follow different philosophies.
>
> > > Furthermore, it looks like a pain in the ass - often you want to run
> > > some initialization code, and without fork() you have to run it as
> > > often as you start processes.
> >
> > On Windows, there's the native API, which is then used by the win32
> > subsystem and posix subsystems to do the job. Native API allows fork()
> > implementations mostly on par with what you get on Unices. MS has a posix
> > subsystem on which fork() performs in the same ballpark as fork() on
> > linux, and make Cygwin's fork() look bad like it deserves. About the only
> > good thing about Cygwin's fork() is that it works on win9x.
>
> Well, there's now SFU for Windows (but only for XP Professional and
> Windows 2003, not for XP Home and Vista, AFAIK). That's a cool solution
> when you want to run Win32 and POSIX programs on the same system, and
> maybe an alternative to using virtualization. But it is nothing for
> developing consumer programs on Windows.
>
> Btw, has something tried to compile O'Caml on SFU? It's a 230M free
> download. There seems to be gcc and lots of GNU stuff, too (yes, it's
> from MS...).
>
> > > Also, Windows is just a bad platform for event-based programs, and you
> > > want to do it to some extent (e.g. for watching all your child
> > > processes). Only for socket handles there is a select() call. For all
> > > other types of handles you cannot find out in advance whether the
> > > operation would block or not.
> >
> > This is misinformation at best, FUD at worst. I'm no Microsoft fanboy,
> > but the reality is quite opposite to what you claim. Windows has quite
> > robust asynchronous I/O support.
>
> No, this is not misinformation, this is the result of digging deeply
> into the Win32 API for an attempt to port Ocamlnet to Win32 (which will
> finally happen to some degree).

If you limit yourself to Win32 API, you're right that you won't get it
to work the way you want to. As soon as you start digging into the DDK,
there are ways to do it.

> There's overlapped I/O, but the 
> difficulty is that you have to start an operation before you can watch
> asynchronously for its completion. There is no way to check in advance
> for that (and that was my claim). Also, there is a quite small limit for
> the number of resources you can watch at the same time (I think 32 or
> 64).
>
> Look at what Cygwin has done. Basically, they start helper threads for
> emulating select(). For some cases, there is no real select() support,
> e.g. the output side of pipes is always considered as writable. Only the
> input side can be watched.

A lot of that is done since they limit themselves to the API, and old
API at that. SFU achieves it without much in the way of limits by using
admittedly undocumented, albeit relatively understandable native APIs,
and by gaining more direct access to the network stack. There's no reason
nowadays why Cygwin folks couldn't do the same.

Cheers, Kuba


  parent reply	other threads:[~2008-07-17 12:48 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-10  5:57 J C
2008-07-10  6:15 ` [Caml-list] " Erik de Castro Lopo
2008-07-10 12:47   ` Oliver Bandel
2008-07-10 13:48     ` Hezekiah M. Carty
2008-07-10 11:35 ` Jon Harrop
2008-07-14 11:32   ` J C
2008-07-14 12:08     ` Jon Harrop
2008-07-14 17:04       ` Mike Lin
2008-07-14 17:28         ` Jon Harrop
2008-07-14 17:16       ` Richard Jones
2008-07-10 13:21 ` Jon Harrop
2008-07-10 13:44 ` Peng Zang
2008-07-10 14:00   ` Jon Harrop
2008-07-10 22:25     ` Richard Jones
2008-07-10 23:04       ` Jon Harrop
2008-07-10 23:41         ` Oliver Bandel
2008-07-11  0:17           ` Oliver Bandel
2008-07-11  9:30             ` Richard Jones
2008-09-21 19:05               ` Michaël Grünewald
2008-09-21 21:41                 ` Jon Harrop
2008-09-22  7:51                   ` Alan Schmitt
2008-09-22 19:03                     ` Jon Harrop
2008-09-22 19:49                       ` David Teller
2008-09-23  6:42                       ` kirillkh
2008-09-24 13:30                       ` [Caml-list] Link tracking Chris Clearwater
2008-09-24 15:43                         ` Jon Harrop
2008-07-11 14:53     ` [Caml-list] thousands of CPU cores Peng Zang
2008-07-15 14:39     ` Kuba Ober
2008-07-19 12:41       ` Oliver Bandel
2008-07-10 19:15 ` Gerd Stolpmann
2008-07-10 20:07   ` Sylvain Le Gall
2008-07-10 20:24     ` [Caml-list] " Gerd Stolpmann
2008-07-10 21:02       ` Sylvain Le Gall
2008-07-10 21:19         ` [Caml-list] " Gerd Stolpmann
2008-07-10 21:35           ` Jon Harrop
2008-07-10 22:39             ` Gerd Stolpmann
2008-07-15 15:57           ` Kuba Ober
2008-07-15 18:03             ` Gerd Stolpmann
2008-07-15 19:23               ` Adrien
2008-07-15 19:45                 ` Adrien
2008-07-16  8:59               ` Michaël Grünewald
2008-07-16 16:43                 ` Gerd Stolpmann
2008-07-16 11:46               ` Richard Jones
2008-07-16 18:35                 ` Erik de Castro Lopo
2008-07-17 12:48               ` Kuba Ober [this message]
2008-07-15 15:21       ` Kuba Ober
2008-07-10 20:48     ` Basile STARYNKEVITCH
2008-07-10 21:12       ` Jon Harrop
2008-07-10 23:33   ` [Caml-list] " Oliver Bandel
2008-07-10 23:43     ` Oliver Bandel
2008-07-11  6:26     ` Sylvain Le Gall
2008-07-11  8:50       ` [Caml-list] " Jon Harrop
2008-07-11  9:29         ` Sylvain Le Gall
2008-07-15 16:01           ` [Caml-list] " Kuba Ober
2008-07-13  3:17         ` Code Mobility [was Re: thousands of CPU cores] Robert Fischer
2008-07-11  3:01   ` [Caml-list] thousands of CPU cores Brian Hurt
2008-07-11 13:01     ` Gerd Stolpmann
2008-07-11 13:43       ` Jon Harrop
2008-07-11 14:03         ` Basile STARYNKEVITCH
2008-07-11 15:08           ` Jon Harrop
2008-07-11 17:28           ` Jon Harrop
2008-07-11 17:54         ` Richard Jones
2008-07-11 18:30           ` Raoul Duke
2008-07-12 17:35       ` Brian Hurt
2008-07-11 15:01     ` Peng Zang
2008-07-12  0:23       ` Oliver Bandel
2008-07-12 22:54         ` J C
2008-07-19 12:06           ` Oliver Bandel
2008-07-11 14:06 ` Xavier Leroy
2008-07-11 15:20   ` Oliver Bandel
2008-07-11 15:23   ` Bill
2008-07-11 18:14   ` Mattias Engdegård
2008-07-12 23:05   ` J C
2008-07-10 23:24 [Caml-list] " Damien Guichard

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=200807170848.18494.ober.14@osu.edu \
    --to=ober.14@osu.edu \
    --cc=caml-list@yquem.inria.fr \
    /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).