From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 5DB78BC57 for ; Tue, 30 Nov 2010 18:40:34 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlQBAEfF9EzAbSoIe2dsb2JhbACDT59EFQEBFiIEHrMckSMNgRSDM3ME X-IronPort-AV: E=Sophos;i="4.59,281,1288566000"; d="scan'208";a="68872969" Received: from einhorn.in-berlin.de ([192.109.42.8]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 30 Nov 2010 18:40:33 +0100 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first (e178036032.adsl.alicedsl.de [85.178.36.32]) (authenticated bits=0) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id oAUHeW5Z018772 for ; Tue, 30 Nov 2010 18:40:33 +0100 Received: by first (Postfix, from userid 1000) id BE97C441BD7; Tue, 30 Nov 2010 18:40:32 +0100 (CET) Date: Tue, 30 Nov 2010 18:40:32 +0100 From: oliver@first.in-berlin.de To: caml-list@yquem.inria.fr Subject: Re: Threading and SharedMem (Re: [Caml-list] Re: Is OCaml fast?) Message-ID: <20101130174032.GB5804@siouxsie> References: <4CF518A6.9000602@planet.nl> <1291133251.16005.604.camel@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1291133251.16005.604.camel@thinkpad> User-Agent: Mutt/1.5.20 (2009-06-14) X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Spam: no; 0.00; in-berlin:01 threading:01 ocaml:01 0100,:01 gerd:01 stolpmann:01 gerd:01 stolpmann:01 model:01 ad-hoc:01 ad-hoc:01 ocaml:01 indirection:01 dienstag:98 blog:98 On Tue, Nov 30, 2010 at 05:07:31PM +0100, Gerd Stolpmann wrote: > Am Dienstag, den 30.11.2010, 16:30 +0100 schrieb Stephan Houben: > > On 11/30/2010 02:22 PM, Gerd Stolpmann wrote: > > > I don't think this is the reason. Many people can ignore Windows, > > > actually. > > > > > > The problem is more that your whole program needs then to be > > > restructured - multi-processing implies a process model (which is the > > > master, which are the workers). With multi-threading you can start > > > threads at all times without having to worry about that (i.e. supports > > > "programming without design" if you want to take that as a negative > > > point). > > > > > > This is what I want to fix with my Netmulticore library - it defines a > > > framework allowing you to start new processes at any time without having > > > to worry about the process hierarchy. > > > > I have in fact read with much interest your blog at > > http://blog.camlcity.org/blog/parallelmm.html . > > > > Your approach there is to really have separate programs for > > server and client. However, one nice thing about fork is that you don't > > have to restructure your program; you can just call fork down somewhere > > in some subroutine where you decide it is convenient, start doing some > > multicore computation, finish and return, and the caller needs never know > > that you did that. So you can indeed program without design using fork. > > Well, I would not recommend that in all cases: fork duplicates all > memory, and if this is a lot, you can end up consuming a lot of RAM. [...] Hence the fork-early recommendation, wich should be a known "rule". But of course this is, what you addressed with "programming without design" would be problematic. But the same also holds for threaded programs, or programs in general. Ad-hoc code is often a good way to just start something, but after a while one should start design... and I mean... long before release. ;) And doing the design after starting with ad-hoc code is done even better with a language that makes refactoring easy. (And this is the reason why we are on the Caml-list :)) Some people might even start with the design... and I think a rigid type system like OCaml supports design, because starting with types can give a good starting point in a design. So I experienced that starting with types (and interface) can make things very clear from the beginning. But of course this only helps, if you have clear so far, what you want to achieve (a clear, distinct task). But somehow this becomes off-topic and would be a separate discussion. [...] > > Of course, the advantage of your approach is that you can now distribute > > the work over multiple machines. So I guess there is an appropriate > > place for all of these techniques. > > I was recently working on an improved fork machinery, with some > indirection between the request for creating a new worker process, and > the actual fork. That's this netmulticore library I'm talking about. The > new process is not a child of the process requesting the creation, but > always a child of a common master process. [...] So, you ask for new sisters and brothers.... ...and the parent can be slim. Ciao, Oliver