From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id DC3707EC6E for ; Fri, 17 Jan 2014 17:22:56 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of markus.mottl@gmail.com) identity=pra; client-ip=209.85.212.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="markus.mottl@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of markus.mottl@gmail.com designates 209.85.212.180 as permitted sender) identity=mailfrom; client-ip=209.85.212.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="markus.mottl@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f180.google.com) identity=helo; client-ip=209.85.212.180; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="postmaster@mail-wi0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsECAJFf2FLRVdS0lGdsb2JhbABZg0NKDKgokmmBBwgWDgEBAQEHCwsJEiqCJQEBAQRAARQHEgsBAwwGBQsNDSEhAQERAQUBChIGExKHXQEDEQ2dDoxcgwmSFAoZJwMKZIRyEQEFDIxfghQHhDgEiUeMboFsgTGLK4NOGCmEdx4 X-IPAS-Result: AsECAJFf2FLRVdS0lGdsb2JhbABZg0NKDKgokmmBBwgWDgEBAQEHCwsJEiqCJQEBAQRAARQHEgsBAwwGBQsNDSEhAQERAQUBChIGExKHXQEDEQ2dDoxcgwmSFAoZJwMKZIRyEQEFDIxfghQHhDgEiUeMboFsgTGLK4NOGCmEdx4 X-IronPort-AV: E=Sophos;i="4.95,674,1384297200"; d="scan'208";a="45203922" Received: from mail-wi0-f180.google.com ([209.85.212.180]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 17 Jan 2014 17:22:56 +0100 Received: by mail-wi0-f180.google.com with SMTP id d13so915457wiw.13 for ; Fri, 17 Jan 2014 08:22:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=1HAHuKbvl8NdxxnesNajmqpI7AidWfpn77FfXZIQm5I=; b=r8nUNaDLh01rpkaq2T1BKE+NrVfBBdOmzAYHZiCkjpriGVOlsU68QFxgMMIQBQ54Iy tf/VKOwTyXeKOToaWK6260x94U2FftWoAfnLoqNooEXJRsEDuM+kMA6mPaOktSYe+22U lNMSCkviouOwC3leY6sx6keV7CVON+MUmpKa62LR7lZIZt5GYTeBgIVBK3TXRasxOAVU N5Sp29MwV4PWfmntsfKgtgfkiGql3A4Fim5bJHqzlX18MHOOM6wJUxKvZECTPqPSmzI2 McqC+NJ95zR3T2TxZrmkpy5e76rnLYqLoMDkv2oThSUGnypI3rdf1NH6Sz96ElrXrwoe kRKQ== MIME-Version: 1.0 X-Received: by 10.180.21.244 with SMTP id y20mr3475908wie.37.1389975775835; Fri, 17 Jan 2014 08:22:55 -0800 (PST) Received: by 10.195.13.41 with HTTP; Fri, 17 Jan 2014 08:22:55 -0800 (PST) In-Reply-To: References: <523666417617602473@orange.fr> Date: Fri, 17 Jan 2014 11:22:55 -0500 Message-ID: From: Markus Mottl To: Yotam Barnoy Cc: Damien Guichard , Caml Mailing List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] How much optimized is the 'a option type ? Cross-module inlining (even across compilation units) is already supported. I guess what you mean is whether functor arguments are inlined, which is not yet the case. There has been some recent work on this: http://www.ocamlpro.com/blog/2013/07/11/inlining-progress-report.html I'd really love to see something like that in the compiler. Regards, Markus On Fri, Jan 17, 2014 at 10:49 AM, Yotam Barnoy wrote: > That reminds me -- what is the situation regarding inlining? Is there work > being done on inlining from other modules? Is heavy inlining being done > within a module? Would it be possible to annotate with [@@inline] to give > hints to the compiler at some point? > > -Yotam > > > On Fri, Jan 17, 2014 at 9:36 AM, Markus Mottl > wrote: >> >> Others have already answered about memory representation, but there is >> one thing about allocations that many OCaml programmers may not yet be >> aware of and that can make a noticeable performance difference when >> used wisely: the OCaml compiler will inspect your code and, under the >> right conditions, batch together allocations. E.g. consider this >> function (references are records, btw.): >> >> let f n = >> let x = ref (ref (Some (Some n))) in >> [(x, n); (x, n)] >> >> One might naively assume that this would lead to seven or so >> allocations. But if you inspect the assembly, you'll see only one >> allocation followed by mere initialization assignments. >> >> Such allocation batches can break if, for example, the code calls >> non-inlined (e.g. recursive or external) functions. I'm not quite >> sure about all the rules there, but it's generally trivial to just >> look at the assembler output to find out what the compiler is doing. >> In some cases merely calling all functions before any allocations take >> place can speed up your code. There are even cases where it may be >> more efficient to allocate several values in one chunk though only >> some may be needed depending on branches taken later. >> >> Regards, >> Markus >> >> On Fri, Jan 17, 2014 at 2:35 AM, Damien Guichard >> wrote: >> > Hello, >> > >> > Compared to the code : >> > >> > type 'a option = None | Some of 'a >> > >> > How do an 'a option value performs ? >> > Any allocation saved ? >> > Any indirection removed ? >> > >> > Is 'a option just like any sum type ? >> > Or is 'a option more like an ANSI C pointer type ? >> > >> > Regards, >> > >> > Damien Guichard >> > >> > >> > >> > -- >> > 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