From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id B07DABBAF for ; Fri, 11 Jul 2008 17:09:27 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AogGAO8Td0jUnw6GZWdsb2JhbACCOI9vEgIeA5xs X-IronPort-AV: E=Sophos;i="4.30,345,1212357600"; d="scan'208";a="13037869" Received: from pih-relay08.plus.net ([212.159.14.134]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 11 Jul 2008 17:09:27 +0200 Received: from [90.192.139.241] (helo=beast.local) by pih-relay08.plus.net with esmtpa (Exim) id 1KHKFR-0007G5-Mn for caml-list@yquem.inria.fr; Fri, 11 Jul 2008 16:09:25 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] thousands of CPU cores Date: Fri, 11 Jul 2008 16:08:03 +0100 User-Agent: KMail/1.9.9 References: <200807111443.53853.jon@ffconsultancy.com> <48776844.3050708@starynkevitch.net> In-Reply-To: <48776844.3050708@starynkevitch.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200807111608.03694.jon@ffconsultancy.com> X-Plusnet-Relay: b8eb2ed8ed999bdfeef1975bc46dad16 X-Spam: no; 0.00; basile:01 avoided:01 ocaml:01 haskell:01 ocaml:01 ocaml's:01 compilation:01 run-time:01 unboxed:01 run-time:01 bytecode:01 nativecode:01 multithread:01 wrappers:01 boehm:01 On Friday 11 July 2008 15:03:48 Basile STARYNKEVITCH wrote: > It is not specific to Linux (and probably not even to *opensource* > functional programming languages; I believe proprietary functional > languages implementations face the same problems). Indeed, Mathematica has the same problem but, I believe, Wolfram Research are migrating it to the JVM for this reason. > In my perception, > functional programming requires *blindly fast* memory allocation for > values which are becoming garbage quickly. This seems a property of > functional programming (and more generally any programming style > discouraging side effects), in other words functional programming need > very efficient garbage collectors (A.Appel wrote stuff on this almost > 20? years ago). Although that is established functional folklore, I believe it is misguided to try to apply that to more mainstream concerns. Moreover, the problem can be largely avoided by adopting a more modern JIT-based approach to language implementation anyway. OCaml and its ancestors and relatives like Haskell have traditionally been used by academics for applications with the value lifetime distribution that you describe (very high allocation rates for short lived values) when it is not unusual to see 30% CPU time spent in the GC. However, OCaml really pioneered the use of this family of languages in completely different applications such as numerical methods for scientific computing thanks to OCaml's unusually good floating point performance. Such applications do not share the characteristic that you describe but they still benefit enormously from first-class functions, tail calls, an expressive static type system and so on. These applications benefit far more from good code generation than from a fast GC and it is now unusual to see >5% CPU time spent in the GC for most OCaml programs. Type specialization during JIT compilation removes the need for a uniform run-time representation of values which, amongst other things, obviates all boxing of floats. Value types allow custom data structures to be stored unboxed when appropriate (e.g. complex numbers). This is why F# can be so productive for high-performance numerics even though it is built upon a run-time that was specifically designed for C#'s characteristics. > As a case in point, I suggest an experiment (which unfortunately I don't > have the time or motivation to realize). Replace the current Ocaml GC > either in bytecode or in nativecode ocaml by Boehm's collector (which is > multithread compatible). I'm sure you'll get a significant performance > loss, but you should gain the true multi-threading feature. Of course, > synchronization issues will appear, very probably in application code > (and some C function wrappers). That is an interesting idea and, in fact, perhaps LLVM+Boehm would be the easiest way to create a new functional language implementation that captures F#'s productivity. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e