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 4E0637EE79 for ; Thu, 21 Apr 2016 13:45:55 +0200 (CEST) IronPort-PHdr: 9a23:O4SAPRfO3p9pN7DV3D2/fFCmlGMj4u6mDksu8pMizoh2WeGdxc6ybR7h7PlgxGXEQZ/co6odzbGG4+a+CSdcuN6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDivcODKFkRzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IeezAcq85Vb1VCig9eyBwvZWz9Er1dhaU/nYXTkkRlxNJBUCFsEC7Dd/NtX7Ysex0w2G4MMvtQLZ8DTagx6ZwUwL1ziwAMmhq3nvQj5lBhbhcplqEphpkwJ+cNJCQNfxlfbL1f9ocSHFdRMtcS2pKBYbqPNhHNPYIIesN99q1nFAJtxbrQFT1CQ== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=yminsky@janestreet.com; spf=Pass smtp.mailfrom=yminsky@janestreet.com; spf=None smtp.helo=postmaster@mxout3.mail.janestreet.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of yminsky@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of yminsky@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.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@mxout3.mail.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="postmaster@mxout3.mail.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0B7AAAXvRhXiuXIaSZeFoN1fQapCiqEWYZqg3x2AQ2BciSCOoMwAoEmBzgUAQEBAQEBAQERAQEBCBYJUIItghQBAQEDARIRBBkBASwLAQQLCwQHAwoNHQICIQESAQUBChIGEwgKEIdzAwoIAwugMYExPjGKT2eEQQEEh1YDCoRwAQEBAQEBAQECAQEBAQEBAQEBARAGCoYXhEuCQYFIY4JTglYBhjcMkR8xhXuCdYMugXaCNIxch0+GIREegQ4PDwEBgjkegW9QAYhGAQEB X-IPAS-Result: A0B7AAAXvRhXiuXIaSZeFoN1fQapCiqEWYZqg3x2AQ2BciSCOoMwAoEmBzgUAQEBAQEBAQERAQEBCBYJUIItghQBAQEDARIRBBkBASwLAQQLCwQHAwoNHQICIQESAQUBChIGEwgKEIdzAwoIAwugMYExPjGKT2eEQQEEh1YDCoRwAQEBAQEBAQECAQEBAQEBAQEBARAGCoYXhEuCQYFIY4JTglYBhjcMkR8xhXuCdYMugXaCNIxch0+GIREegQ4PDwEBgjkegW9QAYhGAQEB X-IronPort-AV: E=Sophos;i="5.24,512,1454972400"; d="scan'208,217";a="215269644" Received: from mxout3.mail.janestreet.com ([38.105.200.229]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Apr 2016 13:45:32 +0200 Received: from tot-qpr-mailcore2.delacy.com ([172.27.56.106] helo=tot-qpr-mailcore2) by mxout3.mail.janestreet.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82) (envelope-from ) id 1atD34-0003wn-MD for caml-list@inria.fr; Thu, 21 Apr 2016 07:45:30 -0400 X-JS-Flow: external Received: by tot-qpr-mailcore2 with JS-mailcore (0.1) (envelope-from ) id BXGL1a-AAABgU-Tl; 2016-04-21 07:45:30.627443-04:00 Received: from mail-vk0-f72.google.com ([209.85.213.72]) by mxgoog1.mail.janestreet.com with esmtps (UNKNOWN:AES128-GCM-SHA256:128) (Exim 4.72) (envelope-from ) id 1atD34-0007tt-HF for caml-list@inria.fr; Thu, 21 Apr 2016 07:45:30 -0400 Received: by mail-vk0-f72.google.com with SMTP id f185so150779498vkb.3 for ; Thu, 21 Apr 2016 04:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=F+9GaPKAX/58Up75dxhfW0Jl/DQoEHQJdC/JXyvfBqg=; b=zs+CG5qaONZGX6quNKZpoTCKK/aIUDKxWgG9384Of9cogWNRUgT4eglSITH5O40ISM rWj1QS4VSlEurzunTm4onV8Fs95SMG2Nk/p6H6EmKSxabOTj9AdAw7kMOx7s6FnN3Xuo 1XozgvsW59Iow0O6dck4S7e1awnnSfu8RODHM= 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=F+9GaPKAX/58Up75dxhfW0Jl/DQoEHQJdC/JXyvfBqg=; b=bK7k61SQ9sdRQdcAErdnbzu8BxdEkZAT+RPwX9qXJ+GjsAZK/N8uwaEcBe+d/zBi7D m+KTsChQhHEgTBgE5dnJbSZTMpmu9edwkv0bRfnAWBWMEVMzoBL1CkzwGBGXxSvZW8GH kzqtDCyEuHhIRIfvszCH+ximRJR5j1CrkXqSTs9yQdPbMFYJnW82xU1XzPUijBFiByHL R4AD5Tc0dTYHiye57ipN2aCO7WewYqX4ixqqwy8hNG8Bc4+zRTBR00JPV9kJAstinIcI tsBogA1Kknbc1vk7eLZsWb0eVFTZCrqztODmUoLPzQ3AwtiIA4G34owAhpUB6Tjgg05G d5vA== X-Gm-Message-State: AOPr4FU7g+Hyaizk3HhRICJ7ASbx+2oozUUq28tS3VXq+u/LRGFm0DLDtpuvW3yZM7TPHqgsZxcVkeVTLNfQ4blPrJKN6222eBEUGUPcFIMdtXX8hIRejZpAmGhJFyluRR7mdWFRiSl5qFYhsZaXhoUkMo/ADlBluNu0Ao9+9sU= X-Received: by 10.13.205.69 with SMTP id p66mr8778571ywd.255.1461239130253; Thu, 21 Apr 2016 04:45:30 -0700 (PDT) X-Received: by 10.13.205.69 with SMTP id p66mr8778557ywd.255.1461239130043; Thu, 21 Apr 2016 04:45:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.208.133 with HTTP; Thu, 21 Apr 2016 04:45:10 -0700 (PDT) In-Reply-To: References: From:Yaron Minsky Date: Thu, 21 Apr 2016 07:45:10 -0400 Message-ID: To:Jonas Jensen Cc:Gregory Malecha , caml users Content-Type: multipart/alternative; boundary=001a114e582447493c0530fd3fc6 X-JS-Processed-by: mailcore Subject: Re: [Caml-list] Question about Optimization --001a114e582447493c0530fd3fc6 Content-Type: text/plain; charset=UTF-8 Also, Core_kernel's Sequence type fills a similar purpose. And Flambda does a good job of optimizing the iteration in Sequence, from what I've overheard about our experiments. On Thu, Apr 21, 2016 at 5:32 AM, Jonas Jensen wrote: > On 21 April 2016 at 09:13, Gregory Malecha wrote: > > > > I'm wondering if there is any work (and interest) on supporting > user-defined optimizations similar to GHC's rewrite rules in the Ocaml > compiler. For example, a standard example would be specifying map fusion: > > > > map f (map g ls) = map (fun x -> f (g x)) ls > > A "boring" and practical answer is that you get this optimization by > writing your long chain of map, filter, bind, etc. using Batteries' > Enum ( > http://ocaml-batteries-team.github.io/batteries-included/hdoc2/BatEnum.html > ) > or the stand-alone Gen package > (http://cedeela.fr/~simon/software/gen/Gen.S.html). It looks > superficially like list map, but the order of execution will be like > after a fusion, which should improve cache locality and avoid > allocations of intermediate lists. > > Cheers, > Jonas > > -- > 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 > --001a114e582447493c0530fd3fc6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Also, Core_kernel's Sequence type fills a similar purp= ose.=C2=A0 And Flambda does a good job of optimizing the iteration in Seque= nce, from what I've overheard about our experiments.

On Thu, Apr 21, 2016 at 5:32 A= M, Jonas Jensen <jj@issuu.com> wrote:
On 21 April 2016 at 09:13, Gregory Malecha <gmalecha@gmail.com> wrote:
>
> I'm wondering if there is any work (and interest) on supporting us= er-defined optimizations similar to GHC's rewrite rules in the Ocaml co= mpiler. For example, a standard example would be specifying map fusion:
>
> map f (map g ls) =3D map (fun x -> f (g x)) ls

A "boring" and practical answer is that you get this optim= ization by
writing your long chain of map, filter, bind, etc. using Batteries'
Enum (http://ocaml-batter= ies-team.github.io/batteries-included/hdoc2/BatEnum.html)
or the stand-alone Gen package
(http://cedeela.fr/~simon/software/gen/Gen.S.html). It looks
superficially like list map, but the order of execution will be like
after a fusion, which should improve cache locality and avoid
allocations of intermediate lists.

Cheers,
Jonas

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocam= l_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--001a114e582447493c0530fd3fc6--