caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Mark Shinwell <mshinwell@janestreet.com>
To: Markus Mottl <markus.mottl@gmail.com>
Cc: Yotam Barnoy <yotambarnoy@gmail.com>,
	Alain Frisch <alain.frisch@lexifi.com>,
	OCaml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Status of Flambda in OCaml 4.03
Date: Thu, 10 Mar 2016 07:20:20 +0000	[thread overview]
Message-ID: <CAM3Ki77_C2_KFKxAEhn+FwAYqWpVVdhPK2o8vD---7R6Frd9AQ@mail.gmail.com> (raw)
In-Reply-To: <CAP_800pnJRxLatZmtMTu=xMfdreGV4XmnhW9T5KMa7U2uPRRcg@mail.gmail.com>

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 <markus.mottl@gmail.com> 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 <yotambarnoy@gmail.com> 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 <markus.mottl@gmail.com> 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 <mshinwell@janestreet.com>
>>> 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 <markus.mottl@gmail.com> 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 <alain.frisch@lexifi.com>
>>> >> 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

  reply	other threads:[~2016-03-10  7:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08 22:10 Markus Mottl
2016-03-08 22:53 ` Alain Frisch
2016-03-09  3:55   ` Markus Mottl
2016-03-09  7:14     ` Mark Shinwell
2016-03-10  0:59       ` Markus Mottl
2016-03-10  1:32         ` Yotam Barnoy
2016-03-10  1:43           ` Markus Mottl
2016-03-10  7:20             ` Mark Shinwell [this message]
2016-03-10 15:32               ` Markus Mottl
2016-03-10 15:49                 ` Gabriel Scherer
2016-04-17  8:43                   ` Jesper Louis Andersen
2016-04-17  8:59                     ` Mohamed Iguernlala
2016-04-17 15:43                       ` Markus Mottl
2016-03-10 20:12                 ` [Caml-list] <DKIM> " Pierre Chambart
2016-03-10 21:08                   ` Markus Mottl
2016-03-10 22:51                   ` Gerd Stolpmann
2016-03-11  8:59                     ` Mark Shinwell
2016-03-11  9:05                       ` Mark Shinwell
2016-03-11  9:09                       ` Alain Frisch
2016-03-11  9:26                         ` Mark Shinwell
2016-03-11 14:48                           ` Yotam Barnoy
2016-03-11 15:09                             ` Jesper Louis Andersen
2016-03-11 16:58                       ` Markus Mottl

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=CAM3Ki77_C2_KFKxAEhn+FwAYqWpVVdhPK2o8vD---7R6Frd9AQ@mail.gmail.com \
    --to=mshinwell@janestreet.com \
    --cc=alain.frisch@lexifi.com \
    --cc=caml-list@inria.fr \
    --cc=markus.mottl@gmail.com \
    --cc=yotambarnoy@gmail.com \
    /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).