From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 1D51B7FE53 for ; Thu, 10 Mar 2016 16:50:20 +0100 (CET) IronPort-PHdr: 9a23:yuMQlhZ2mFtuUQuuZH9FXjz/LSx+4OfEezUN459isYplN5qZpMy/bnLW6fgltlLVR4KTs6sC0LqJ9fCwEjNeqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh7/0q82YPFsArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIZoGJ/3dKUgTLFeEC9ucyVsvJWq5i/4UBCX63AAfmITmxtOS0iZvVCpFqv25w7zrOlgw2G/OtHqSfhgXD247LpwDhrvlDsDHzE8+WDTzMd3ifQIjgimoklQyoTOYYyRfMF1fq7HcMlSEWVIVNxQWigHGYi8YpECFcIOOO9Zq8/2oF5Y/kj2PhWlGO66kmwAvXTxx6Bvlrl4HA== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gabriel.scherer@gmail.com; spf=Pass smtp.mailfrom=gabriel.scherer@gmail.com; spf=None smtp.helo=postmaster@mail-io0-f171.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.223.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.223.171 as permitted sender) identity=mailfrom; client-ip=209.85.223.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-io0-f171.google.com) identity=helo; client-ip=209.85.223.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-io0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CuAAB8l+FWkqvfVdFeg1w0bQaoUIFOkDoBDYFtIYVuAoE6BzgUAQEBAQEBAQEQAQEBAQcLCwkhL4ItghUBAQQSER0BFAcSCwEDDAYFCw0CAgkdAgIhAQERAQUBChIGExIQh2wBAxIOoEmBMT4xizaBaoJXhUYKGScDClGDdAEBAQEBAQQBAQEBAQEBEwEFCgVthRyDRH6CPYR9gToFhh4Mh32JFYFOhByGGYF1gWRLhyGFL4cahhIRHoEPHgEBgjgNEQiBZh4uiVMBAQE X-IPAS-Result: A0CuAAB8l+FWkqvfVdFeg1w0bQaoUIFOkDoBDYFtIYVuAoE6BzgUAQEBAQEBAQEQAQEBAQcLCwkhL4ItghUBAQQSER0BFAcSCwEDDAYFCw0CAgkdAgIhAQERAQUBChIGExIQh2wBAxIOoEmBMT4xizaBaoJXhUYKGScDClGDdAEBAQEBAQQBAQEBAQEBEwEFCgVthRyDRH6CPYR9gToFhh4Mh32JFYFOhByGGYF1gWRLhyGFL4cahhIRHoEPHgEBgjgNEQiBZh4uiVMBAQE X-IronPort-AV: E=Sophos;i="5.24,316,1454972400"; d="scan'208";a="207057876" Received: from mail-io0-f171.google.com ([209.85.223.171]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 10 Mar 2016 16:50:07 +0100 Received: by mail-io0-f171.google.com with SMTP id z76so110687345iof.3 for ; Thu, 10 Mar 2016 07:50:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=4jEs+Ol0O+LcAeJlqrf2AQKw/WxvEqGDmQl5aYKPxQw=; b=JmvLC+CpKm8P5KVoXAFpI21BcMlQclh9KXv66HxCnR11I4PediwMLB7DddlCvLbsze 5FmrrrWSoUEXfsWZfDRhqX1rUQcGpSC3wDkziV8DhlSOlsIUP7Z5ACx8A08eI+UuS1i1 0GMA5x3/OPgAjR7qi9MV9m82FIT4LpUijzi3QEzSWU0kkLcPLtzfoTeU7a7PIN52F1qZ UL3xXfcK5GN/gG7qDJJrpQmgxlrAlfT80mF8ariNXGOqhFxM+Nfap+Ez/2VoCLTrlCXF 5Pd1J4batjo4nK0S4PMCCWgoW2LYVhpZdwQcEexewkJUvrnjVxlgJ3EVxPNChePA5LJY AuBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=4jEs+Ol0O+LcAeJlqrf2AQKw/WxvEqGDmQl5aYKPxQw=; b=NHjdd9PFD6dQLEDtkah0BWwOEGpxzJ/+46w4FNNUO6xwlPdj9T5F5jn7FV+MJk/Yhm u+f1vKQgPVQ7Q4WvgVoFWkehqTZNQX8eReYJxVdzg5CFpDReQqTa6o0ulhLFDcL/K+kk So84s9YYiuHcl0nkLkTYlxCkU5HWlqlwE2SroI5CEcoYEXzpS4kx3Yup3H9Kn1/cYiGw NVa5+JRzRi+4KO9rAiW7PbSf7eZ/ytVUk1tyHRKrcKJNyFq3VEArURhd/waCQLPXXEwi fy9YBek4g6xUL3Mi7t7gQGmiLBenhdqcjYwetuc2lhhGV23OOcz99rXFUcKJ3jgnnDLy uiAQ== X-Gm-Message-State: AD7BkJJU5zOpC00vduW/Oa9RGfFK5sMOIe+l1+0RiU1gD2RdtORQqGYMiy5WEspWiF5fbqPRfbEXvDyCs2mtGg== X-Received: by 10.107.47.163 with SMTP id v35mr4082476iov.19.1457625006257; Thu, 10 Mar 2016 07:50:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.17.4 with HTTP; Thu, 10 Mar 2016 07:49:26 -0800 (PST) In-Reply-To: References: <56DF57FA.9070309@lexifi.com> From: Gabriel Scherer Date: Thu, 10 Mar 2016 10:49:26 -0500 Message-ID: To: Markus Mottl Cc: Mark Shinwell , Yotam Barnoy , Alain Frisch , OCaml List Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Status of Flambda in OCaml 4.03 One point that is tangentially related to your message is that the flambda people observed that it's easy to miss cross-module optimizations because .cmx files are missing -- the compiler is silent about this. Leo White added a new warning (58) when a module does not find the .cmx of one of its dependencies, which interacts with -opaque (initially introduced in 4.02.0 when compiling implementation files) in the following way. In 4.03, you can compile an *interface* with -opaque, announcing the intent not to provide an .cmx file (or to choose among several implementations at link-time) for its implementation(s). Warning 58 will not warn about a missing .cmx if the dependency's interface was compiled opaque. https://github.com/ocaml/ocaml/pull/319 I think the long-term plan is to encourage people to enable the warning, and explicitly use -opaque on .cmi when it is their intent not to distribute .cmx files. That said, those things may be refined once we get more experience of flambda in the wild. On Thu, Mar 10, 2016 at 10:32 AM, Markus Mottl wrote: > Ok, that explains things. Is it realistic to assume that the size of > .cmx files can be substantially reduced? It seems there is a natural > tradeoff between "optimize well" and "compile fast". I suspect it may > be inevitable to add more compilation files. We actually already have > that situation with native code libraries: the .cmxa file is enough to > compile a project, but if the .cmx files of contained modules are > visible in the path, too, then, and only then, the compiler can and > will do cross-module inlining - which takes longer, of course. > > What about the following approach? - There is one "minimal" set of > compilation files that always allows you to quickly obtain a running > (albeit slow / large) executable. Additional compilation files then > monotonically augment this information and can be produced and > consumed optionally depending on compilation flags. The nice thing > about this approach is that you don't necessarily have to recompile > the whole project with different flags whenever you need a different > compile time / performance tradeoff. E.g. if Flambda information is > available for an unchanged file, you don't have to rebuild it when > needed. If you just want to compile quickly, you don't have to read > data you don't need. Separate compilation files would also integrate > much better with build tools (timestamping, etc.). > > I guess we would already be looking at OCaml version 5 for such a change :) > > On Thu, Mar 10, 2016 at 2:20 AM, Mark Shinwell wrote: >> By "enabled at configure time" I mean that you need to pass the >> "-flambda" option to the configure script when building the compiler. >> >> The main reason Flambda isn't enabled by default is because we need to >> do further work to improve compile-time performance. There are also >> concerns about .cmx file size. Flambda produces larger .cmx files: it >> stores the entire intermediate representation of the compilation unit >> so that no subsequent cross-module inlining decision is compromised. >> >> There is a mode, -Oclassic, which uses Flambda but mimics the >> behaviour of the existing compiler; unfortunately this isn't really >> fast enough yet either and .cmx sizes aren't small enough. >> >> When we manage to address some of these issues further, hopefully for >> 4.04, we will revisit whether Flambda should be enabled by default. >> >> One of the main reasons there is a configure option rather than a >> runtime switch is to avoid having to re-engineer the compiler's build >> system to permit multiple builds of the various libraries (the stdlib, >> for example) with differing options that affect what appears in the >> .cmx files (e.g. with and without Flambda). Even if code were used to >> allow Flambda to read non-Flambda .cmx files, performance degradation >> would result. >> >> Mark >> >> On 10 March 2016 at 01:43, Markus Mottl wrote: >>> I agree with Yotam. Assuming that Flambda produces correct code and >>> doesn't cause any serious performance issues either with the generated >>> code or with excessive compile times, I'd prefer building it into the >>> compiler by default. I'd be fine if I had to pass an extra flag at >>> compile time to actually run Flambda optimizers, but it should at >>> least be available. It doesn't have to be perfect to be useful. >>> >>> On Wed, Mar 9, 2016 at 8:32 PM, Yotam Barnoy wrote: >>>> While we await the manual, can you explain what you mean by 'enabled at >>>> configure time'? Will a -flambda -O-something argument passed to the normal >>>> 4.03 compiler enable flambda optimizations? Flambda is clearly the star of >>>> the 4.03 release, so not enabling it using command line options seems >>>> counter-intuitive (if this is the case). >>>> >>>> -Yotam >>>> >>>> On Wed, Mar 9, 2016 at 7:59 PM, Markus Mottl wrote: >>>>> >>>>> I've just tested Flambda, and it seems to already be doing a pretty >>>>> decent job on some non-trivial examples (e.g. inlining combinations of >>>>> functors and first class functions). I hope there will be a stable >>>>> 4.03 OPAM switch that enables it. I'm looking forward to being able >>>>> to write more elegant, abstract code that's still efficient. >>>>> >>>>> Regards, >>>>> Markus >>>>> >>>>> On Wed, Mar 9, 2016 at 2:14 AM, Mark Shinwell >>>>> wrote: >>>>> > It will not be enabled by default in 4.03. For the majority of >>>>> > programs, in the current state, it should improve performance (mainly >>>>> > by lowering allocation). It should never generate wrong code. >>>>> > However we know of examples that don't improve as much as we would >>>>> > like, which we will try to address for 4.04. >>>>> > >>>>> > There will be a draft version of the new Flambda manual chapter >>>>> > available shortly (hopefully this week). Amongst other things this >>>>> > documents what you found about the configure options and the flags' >>>>> > operation. >>>>> > >>>>> > Mark >>>>> > >>>>> > On 9 March 2016 at 03:55, Markus Mottl wrote: >>>>> >> Hi Alain, >>>>> >> >>>>> >> I see, thanks. It was a little confusing, because the command line >>>>> >> options for tuning flambda were still available even without Flambda >>>>> >> being enabled. >>>>> >> >>>>> >> Will Flambda be enabled by default in OCaml 4.03 or is it still >>>>> >> considered to be too experimental? It could turn out to become one of >>>>> >> the most impactful new features in terms of how I write code. >>>>> >> >>>>> >> Regards, >>>>> >> Markus >>>>> >> >>>>> >> On Tue, Mar 8, 2016 at 5:53 PM, Alain Frisch >>>>> >> wrote: >>>>> >>> Hi Markus, >>>>> >>> >>>>> >>> flambda needs to be enabled explicitly at configure time with the >>>>> >>> "-flambda" >>>>> >>> flag. The new optimizer will then be used unconditionally, and you >>>>> >>> can >>>>> >>> tweak it using command-line parameters passed to ocamlopt (see >>>>> >>> "ocamlopt >>>>> >>> -h"). >>>>> >>> >>>>> >>> >>>>> >>> Alain >>>>> >>> >>>>> >>> >>>>> >>> On 08/03/2016 23:10, Markus Mottl wrote: >>>>> >>>> >>>>> >>>> Hi, >>>>> >>>> >>>>> >>>> I'm trying out OCaml 4.03.0+beta1 right now and wanted to test >>>>> >>>> Flambda >>>>> >>>> optimizations. But looking at the generated assembly, it doesn't >>>>> >>>> seem >>>>> >>>> to be doing much if anything on the simple test examples that I >>>>> >>>> thought would benefit. >>>>> >>>> >>>>> >>>> To give an example of what I expected to see, lets consider this >>>>> >>>> code: >>>>> >>>> >>>>> >>>> ----- >>>>> >>>> let map_pair f (x, y) = f x, f y >>>>> >>>> >>>>> >>>> let succ x = x + 1 >>>>> >>>> let map_pair_succ1 pair = map_pair succ pair >>>>> >>>> let map_pair_succ2 (x, y) = succ x, succ y >>>>> >>>> ----- >>>>> >>>> >>>>> >>>> I would have thought that the "succ" function would be inlined in >>>>> >>>> "map_pair_succ1" as the compiler would do for "map_pair_succ2". >>>>> >>>> But the generated code looks like this: >>>>> >>>> >>>>> >>>> ----- >>>>> >>>> L101: >>>>> >>>> movq %rax, %rdi >>>>> >>>> movq %rdi, 8(%rsp) >>>>> >>>> movq %rbx, (%rsp) >>>>> >>>> movq 8(%rbx), %rax >>>>> >>>> movq (%rdi), %rsi >>>>> >>>> movq %rdi, %rbx >>>>> >>>> call *%rsi >>>>> >>>> L102: >>>>> >>>> movq %rax, 16(%rsp) >>>>> >>>> movq (%rsp), %rax >>>>> >>>> movq (%rax), %rax >>>>> >>>> movq 8(%rsp), %rbx >>>>> >>>> movq (%rbx), %rdi >>>>> >>>> call *%rdi >>>>> >>>> ----- >>>>> >>>> >>>>> >>>> Is Flambda supposed to work out of the box with the current beta? >>>>> >>>> What flags or annotations should I use for testing? Any showcase >>>>> >>>> examples I should try out that are expected to be improved? >>>>> >>>> >>>>> >>>> Regards, >>>>> >>>> Markus >>>>> >>>> >>>>> >>> >>>>> >> >>>>> >> >>>>> >> >>>>> >> -- >>>>> >> Markus Mottl http://www.ocaml.info markus.mottl@gmail.com >>>>> >> >>>>> >> -- >>>>> >> Caml-list mailing list. Subscription management and archives: >>>>> >> https://sympa.inria.fr/sympa/arc/caml-list >>>>> >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>>>> >> Bug reports: http://caml.inria.fr/bin/caml-bugs >>>>> >>>>> >>>>> >>>>> -- >>>>> Markus Mottl http://www.ocaml.info markus.mottl@gmail.com >>>>> >>>>> -- >>>>> Caml-list mailing list. Subscription management and archives: >>>>> https://sympa.inria.fr/sympa/arc/caml-list >>>>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>>>> Bug reports: http://caml.inria.fr/bin/caml-bugs >>>> >>>> >>> >>> >>> >>> -- >>> Markus Mottl http://www.ocaml.info markus.mottl@gmail.com > > > > -- > Markus Mottl http://www.ocaml.info markus.mottl@gmail.com > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs