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 DFAAA80198 for ; Tue, 11 Jul 2017 19:37:48 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=ivg@ieee.org; spf=Pass smtp.mailfrom=ivg@ieee.org; spf=None smtp.helo=postmaster@mail-yb0-f180.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of ivg@ieee.org) identity=pra; client-ip=209.85.213.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of ivg@ieee.org designates 209.85.213.180 as permitted sender) identity=mailfrom; client-ip=209.85.213.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; 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-yb0-f180.google.com) identity=helo; client-ip=209.85.213.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="postmaster@mail-yb0-f180.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AfNOFvx0KSPJUD31ismDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?seIXLPad9pjvdHbS+e9qxAeQG96KtLQc06L/iOPJYSQ4+5GPsXQPItRndiQuro?= =?us-ascii?q?EopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZv?= =?us-ascii?q?JuTyB4Xek9m72/q89pDXYQhEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+?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ascii?q?Mx6zx9D5ipW9SQDruxiaCMiX/oVqZdYXpLXxXVSS/l?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AoAQBiDGVZhrTVVdFdHgYMGAEFAQsBh?= =?us-ascii?q?BOBFAeFH5pSlzUDXCiFTgKDNwdDFAEBAQEBAQEBAQEBEgEBAQgLCwgoL4IzJAG?= =?us-ascii?q?CQQECAgEjHQEBNwEECwsEBzcCAiISAQUBHAYTiiIFCBCfOT+LH2uCJoMFAQEFi?= =?us-ascii?q?BUBAQEBAQEBAQEBAQEBAQEBAQEYCBKDFoNNhQWFF4JmgmGJaJVBh0iMRIJjgQ+?= =?us-ascii?q?OM5N/FB+BFTaBK4ECCEkaBoQ6Kg8QDIIDJDYBiC0BAQE?= X-IPAS-Result: =?us-ascii?q?A0AoAQBiDGVZhrTVVdFdHgYMGAEFAQsBhBOBFAeFH5pSlzU?= =?us-ascii?q?DXCiFTgKDNwdDFAEBAQEBAQEBAQEBEgEBAQgLCwgoL4IzJAGCQQECAgEjHQEBN?= =?us-ascii?q?wEECwsEBzcCAiISAQUBHAYTiiIFCBCfOT+LH2uCJoMFAQEFiBUBAQEBAQEBAQE?= =?us-ascii?q?BAQEBAQEBAQEYCBKDFoNNhQWFF4JmgmGJaJVBh0iMRIJjgQ+OM5N/FB+BFTaBK?= =?us-ascii?q?4ECCEkaBoQ6Kg8QDIIDJDYBiC0BAQE?= X-IronPort-AV: E=Sophos;i="5.40,347,1496095200"; d="scan'208,217";a="283000415" Received: from mail-yb0-f180.google.com ([209.85.213.180]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 11 Jul 2017 19:37:47 +0200 Received: by mail-yb0-f180.google.com with SMTP id f194so2250267yba.3 for ; Tue, 11 Jul 2017 10:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Pz8jFwMBbp+MTudnnMJIurtbmbrOzVysvlrXj+cro4g=; b=mj1mWluQRGs0gbF4lu9e+kmkX7COOfXHVfkzmxrf9F/dzW9uHsftBuXYUYrQb9+LMV AR9vQ8aJAM+P3iPQLCzC0DSLAOjp4fn7dw+iGtCFdUgIy4xURiYn+9KjQpYw5458QbS6 EBVcTy/pyihgKCEgkJ6+5UMxfl+Qn7Fi3wNiLpHE6uGgncFueVSx9zOy34s5i+9C8KrH ZtiZ/bwwsegQiYXW0yXomHyXvU9BuDi+ZAEZXgEvNcmOP7weC/WoH7MYLCBz1s9aO7SF eUOJVTHPES653rCczGe68dIX76tFr9HY15JWmZHkxadSPg/Bw01gfwunQhtoqec6uQKx GVkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Pz8jFwMBbp+MTudnnMJIurtbmbrOzVysvlrXj+cro4g=; b=OVvu5xTtF6v4WBl6Ne1DXa1sVzPaOtnQEHEsioPN9L0yDKksI2Xw69FcItLFsRGNpG BIkGACO2o0JQLTseLkOE+IQDwt12CMfqqtIdKirhN5o+hxX9I4sTunsOXYoD1oZE9sPz A7RzVbM9a1IRfKZd+Mem80IQEtuM1xrJ/nTZeKU+ptPTzVvHiEZZPoBAR0OildKc0wGr HIDBOnQf1+fasBK3NSCTBmZYxfP7oKJMZiSW7G9LE25wezxj3dtbEInWSbZ+U8afjw/e MZb+RVbb6j0uTlN8eAtbDeRGONGs65TrTQo/KnA3fs1GKfRI09Iiilgng6idA4UXKqqt F1NQ== X-Gm-Message-State: AIVw110tMYDTDxlH0I2678HHbLT0qoiFO8Z55vbKQCjJseSsD8bP4kDv N3DLFS/z6nGeh46/fxuRHKBA8RxQRb0c X-Received: by 10.37.189.135 with SMTP id f7mr83176ybh.218.1499794665781; Tue, 11 Jul 2017 10:37:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.39.7 with HTTP; Tue, 11 Jul 2017 10:37:45 -0700 (PDT) In-Reply-To: <20170711125438.GP21228@nunchakus.loria.fr> References: <20170711125438.GP21228@nunchakus.loria.fr> From: Ivan Gotovchits Date: Tue, 11 Jul 2017 13:37:45 -0400 Message-ID: To: Simon Cruanes Cc: Alexey Egorov , caml users Content-Type: multipart/alternative; boundary="089e0822e5a84a7dd605540e283e" Subject: Re: [Caml-list] Optimizing pure-functional streams --089e0822e5a84a7dd605540e283e Content-Type: text/plain; charset="UTF-8" TWIMC, I've played a little bit with different optimization options in flambda 4.04, and finally, all three versions of the loop: curried, uncurried, and the for-loop, have the same performance, though they still loose about 30% to the C version, due to tagging. Basically, this means, that flambda was able to get rid of the allocation. I don't actually know which of the options finally made the difference, but this is how I compiled it. ocamlopt.opt -c -S -inlining-report -unbox-closures -O3 -rounds 8 -inline-max-depth 256 -inline-max-unroll 1024 -o loop.cmx loop.ml ocamlopt.opt loop.cmx -o loop.native Regards, Ivan On Tue, Jul 11, 2017 at 8:54 AM, Simon Cruanes wrote: > Hello, > > Iterators in OCaml have been the topic of many discussions. Another > option for fast iterators is https://github.com/c-cube/sequence , > which (with flambda) should compile down to loops and tests on this kind > of benchmark. With the attached additional file on 4.04.0+flambda, > I obtain the following (where sequence is test-seq): > > $ for i in test-* ; do echo $i ; time ./$i ; done > test-c_loop > 5000000100000000 > ./$i 0.08s user 0.00s system 97% cpu 0.085 total > test-f_loop > 5000000100000000 > ./$i 0.10s user 0.00s system 96% cpu 0.100 total > test-loop > 5000000100000000 > ./$i 0.18s user 0.00s system 97% cpu 0.184 total > test-seq > 5000000100000000 > ./$i 0.11s user 0.00s system 97% cpu 0.113 total > test-stream > 5000000100000000 > ./$i 0.44s user 0.00s system 98% cpu 0.449 total > > > Note that sequence is imperative underneath, but can be safely used as a > functional structure. > > -- > Simon Cruanes > > http://weusepgp.info/ > key 49AA62B6, fingerprint 949F EB87 8F06 59C6 D7D3 7D8D 4AC0 1D08 49AA > 62B6 > --089e0822e5a84a7dd605540e283e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
TWIMC,=C2=A0

I've played a little b= it with different optimization options in flambda=C2=A04.04, and finally, a= ll three versions of the=C2=A0loop: curried, uncurried, and the for-loop, h= ave the same performance, though they still loose about 30% to the C versio= n, due to tagging.=C2=A0

Basically, this means, th= at flambda=C2=A0was able to get rid of the allocation. I don't actually= know which of the options finally made the difference, but this is how I c= ompiled it.

ocamlopt.opt = -c -S -inlining-report -unbox-closures -O3 -rounds 8 -inline-max-depth 256 = -inline-max-unroll 1024 -o loop.cmx loop.ml
ocamlopt.opt loop.cmx -o loop.native
<= br>
Regards,
Ivan




On Tue, Jul 11, 2017 at 8:54 AM, Simon Cruanes <simon.cruanes.2= 007@m4x.org> wrote:
Hello,<= br>
Iterators in OCaml have been the topic of many discussions. Another
option for fast iterators is https://github.com/c-cube/sequen= ce ,
which (with flambda) should compile down to loops and tests on this kind
of benchmark. With the attached additional file on 4.04.0+flambda,
I obtain the following (where sequence is test-seq):

$ for i in test-* ; do echo $i ; time ./$i ; done
test-c_loop
5000000100000000
./$i=C2=A0 0.08s user 0.00s system 97% cpu 0.085 total
test-f_loop
5000000100000000
./$i=C2=A0 0.10s user 0.00s system 96% cpu 0.100 total
test-loop
5000000100000000
./$i=C2=A0 0.18s user 0.00s system 97% cpu 0.184 total
test-seq
5000000100000000
./$i=C2=A0 0.11s user 0.00s system 97% cpu 0.113 total
test-stream
5000000100000000
./$i=C2=A0 0.44s user 0.00s system 98% cpu 0.449 total


Note that sequence is imperative underneath, but can be safely used as a
functional structure.

--
Simon Cruanes

http= ://weusepgp.info/
key 49AA62B6, fingerprint 949F EB87 8F06 59C6 D7D3=C2=A0 7D8D 4AC0 1D08 49A= A 62B6

--089e0822e5a84a7dd605540e283e--