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 8DC517FDE2 for ; Tue, 31 May 2016 03:14:02 +0200 (CEST) IronPort-PHdr: 9a23:D4uiMx/mjb/cb/9uRHKM819IXTAuvvDOBiVQ1KB80+8cTK2v8tzYMVDF4r011RmSDdSdtq4P17WempujcFJDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIsYL+lS8iP04/riKibwN76XUZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu5blitCLFOXmAvgtI/rpMYwuwwZgf8q9tZBXKPmZOx4COUAVHV1BVso/9XmvgXvSg6G531UEjlH00kAPw+QwxjwRJb8tmPBvepwwiSAdZn5RLouWDmmqbxgSBLyhT0vODsw8WWRgct12vF1uhWk8i122YnSKKSUMuF9b+uJbNYbQ3FCT+5TXipMGZ+mYoYTSeEGOLAL/MHGu1ISoE7mVkGXD+T1x2oN2yb7 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: A0AjAwCr5ExXduXIaSZbhBJ9BoM9pUaFDI13JIVtAoEvBzwQAQEBAQEBAQERAQoWCVCCMIIWAQEEEhEdAQEsCwEPCwsNAgIJHQICIQESAQUBChIGExIQh3MDFwMLnk+BMT4xilRnhEEBAQWIGwMKhB8BAQEBAQEBAQIBAQEBAQEBAQEWCBBxhSaDSoEDgkOBfYMJglmGRgyRNzOGAIYngXmCN4xlh2SGKRIegQ83giSCEFIBiTwBAQE X-IPAS-Result: A0AjAwCr5ExXduXIaSZbhBJ9BoM9pUaFDI13JIVtAoEvBzwQAQEBAQEBAQERAQoWCVCCMIIWAQEEEhEdAQEsCwEPCwsNAgIJHQICIQESAQUBChIGExIQh3MDFwMLnk+BMT4xilRnhEEBAQWIGwMKhB8BAQEBAQEBAQIBAQEBAQEBAQEWCBBxhSaDSoEDgkOBfYMJglmGRgyRNzOGAIYngXmCN4xlh2SGKRIegQ83giSCEFIBiTwBAQE X-IronPort-AV: E=Sophos;i="5.26,393,1459807200"; d="scan'208";a="220368468" 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; 31 May 2016 03:14:00 +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 1b7YFq-0001R7-Ox for caml-list@inria.fr; Mon, 30 May 2016 21:13:58 -0400 X-JS-Flow: external Received: by tot-qpr-mailcore2 with JS-mailcore (0.1) (envelope-from ) id BXTOVW-AAAB3X-W6; 2016-05-30 21:13:58.734209-04:00 Received: from mail-vk0-f70.google.com ([209.85.213.70]) by mxgoog1.mail.janestreet.com with esmtps (UNKNOWN:AES128-GCM-SHA256:128) (Exim 4.72) (envelope-from ) id 1b7YFq-00079j-KH for caml-list@inria.fr; Mon, 30 May 2016 21:13:58 -0400 Received: by mail-vk0-f70.google.com with SMTP id z3so61726093vkg.2 for ; Mon, 30 May 2016 18:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-transfer-encoding; bh=uHNo8kzJwk35SAXG8EHBbc8rsbov3+id5duJHj66I50=; b=Ep8fT08a9zDCJZI0Tm/8YKpivPrskLzvvywgOxq9SGRFWvHEyTvFyD7wm/oMkbgN8P VkZl33OBjCWSBRo794wWY9xrrXwbb6YRPcAJOEJmKjAepTsYYxMsLoKpSba9oTxKqmJN o/zPmjCOPfMnCUkePc/xApv+BcJiSqE5Zpam0= 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:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=uHNo8kzJwk35SAXG8EHBbc8rsbov3+id5duJHj66I50=; b=Nwn/JCgVrspJFZMOpUHqXtbBIEf00af0F6M4keLLZXwVv20YJiod2Ii5zxACJJy50a uf8IthZr3sNqG3new14dgwf1qEnje6BgUmTELlG1wQTx9JtwXI3lMuEk/eHnFhxXwYxi 1phImj0SZlVeht5E2PG7OTjxZX/5eIzTJY4afOtyjys0Q1suTYuDSDpY7oIn2iumCgbh JsA7sPH/mDFbRTUcDY6hbByr6gkROfaW0S/tlpiew2CecYvnfQYC+i51rv+TZPkHcA/p 1/VJXyNShwsp6fEPCLJbusUtmKwCfcDEh8pq0lUintwvPPS1DwfSB4BOJA77Uivlp45Q tmmQ== X-Gm-Message-State: ALyK8tLL5brck4EeWwSlmxfASmI88+YDz9auH2haTDtRJQ98voRZb839QtxO32ZWiQDEyVHvVpUy/nkVLtmdRQlJZOt60R5ttoTIC9TdzSy+wYmvHqj/ckN2gZ+C6i0QZYnp4njbJRXx5M+7mydEMe5w4AOVrDsdLILkhxSWIZ8= X-Received: by 10.37.201.71 with SMTP id z68mr17116981ybf.124.1464657238183; Mon, 30 May 2016 18:13:58 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.37.201.71 with SMTP id z68mr17116976ybf.124.1464657237871; Mon, 30 May 2016 18:13:57 -0700 (PDT) Received: by 10.37.217.75 with HTTP; Mon, 30 May 2016 18:13:57 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 May 2016 21:13:57 -0400 Message-ID: From:Yaron Minsky To:Gabriel Scherer Cc:caml users , Damien Doligez Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-JS-Processed-by: mailcore Subject: Re: [Caml-list] Measuring GC latencies for OCaml program I'm very pleased to see Damien's profiling work picked up and used (and nice to see that OCaml looks pretty good by comparison), and I agree making it easily available by default is a great thing. OCaml lets you be lazy in a few ways --- I know OCaml's excellent type system caused me to be too lazy for too long about testing (though I've long since repented), and OCaml's relatively predictable performance made many of us similarly lazy about profiling. y On Mon, May 30, 2016 at 3:48 PM, Gabriel Scherer wrote: > Dear caml-list, > > You may be interested in the following blog post, in which I give > instructions to measure the worst-case latencies incurred by the GC: > > Measuring GC latencies in Haskell, OCaml, Racket > http://prl.ccs.neu.edu/blog/2016/05/24/measuring-gc-latencies-in-haskel= l-ocaml-racket/ > > In summary, the commands to measure latencies look something like: > > % build the program with the instrumented runtime > ocamlbuild -tag "runtime_variant(i)" myprog.native > > % run with instrumentation enabled > OCAML_INSTR_FILE=3D"ocaml.log" ./main.native > > % visualize results from the raw log > $(OCAML_SOURCES)/tools/ocaml-instr-graph ocaml.log > $(OCAML_SOURCES)/tools/ocaml-instr-report ocaml.log > > While the OCaml GC has had a good incremental mode with low latencies > for most workloads for a long time, the ability to instrument it to > actually measure latencies is still in its infancy: it is > a side-result of Damien Doligez's stint at Jane Street last year, and > 4.03.0 is the first release in which this work is available. > > A practical consequence of this youth is that the "user experience" of > actually performing these measurements is currently very bad. The GC > measurements are activated in an instrumented runtime variant (OCaml > supports having several variants of the runtime available, and > deciding which one to use for a specific program at link-time), which > is the right design choice, but right now this variant is not built by > default by the compiler distribution -- building it is > a configure-time option disabled by default. This means that, as > a user interested in doing the measurements, you have to compile an > alternative OCaml compiler. > Furthermore, processing the raw instrumented log requires tool that > are also in their infancy, and are currently included in the compiler > distribution sources but not installed -- so you have to have a source > checkout available to use them. In contrast, GHC's instrumentation is > enabled by just passing the option "+RTS -s" to the Haskell program of > interest; this is superbly convenient and something we should aim at. > > I discussed with Damien whether we should enable building the > instrumented runtime by default (for example pass > the --with-instrumented-runtime option to the opam switches people are > using, and encourage distributions to use it in their packages as > well). Of course there is a cost/benefit trade-off: currently > virtually nobody is using this instrumentation, but enabling it by > default would increase the compilation time of the compiler > distribution for everyone. (On my machine it only adds 5 seconds to > total build time.) > > I personally think that we should aim for a rock-solid experience for > profiling and instrumenting OCaml program enabled by default=C2=B9. It is > worth making it slightly longer for anyone to install the compiler if > we can make it vastly easier to measure GC pauses in our program when > the need arises (even if it's not very often). But that is > a discussion that should be had before making any choice. > > Regarding the log analysis tools, before finding about Damien's > included-but-not installed tools (a shell and an awk script, in the > finest Unix tradition) I built a quick&dirty OCaml script to do some > measurements, which can be found in the benchmark repository below. It > would not be much more work to grow this in a reusable library to > extract the current log format into a structured data structure -- the > format is undocumented but the provided scripts in tools/ have enough > information to infer the structure. Such a script/library would, of > course, remain tightly coupled to the OCaml version, but I think it > could be useful to have it packaged for users to play with. > > https://gitlab.com/gasche/gc-latency-experiment/blob/master/parse_ocaml= _log.ml > > =C2=B9: We cannot expect users to effectively write performant code if th= ey > don't have the tool support for it. The fact that lazyness in Haskell > makes it harder for users to reason about efficiency or memory usage > has made the avaibility of excellent performance tooling *necessary*, > where it is merely nice-to-have in OCaml. Rather ironically, Haskell > tooling is now much better than OCaml's in this area, to the point > that it can be easier to write efficient code in Haskell. > > Three side-notes on profiling tools: > > 1. `perf record --call-graph=3Ddwarf` works fine for ocamlopt binaries > (no need for a frame-pointers switch), and this is documented: > https://ocaml.org/learn/tutorials/performance_and_profiling.html#Usin= gperfonLinux > > 2. Thomas Leonard has done excellent work on domain-specific profiling > tools for Mirage, and this is the kind of tool support that I think > should be available to anyone out of the box. > http://roscidus.com/blog/blog/2014/08/15/optimising-the-unikernel/ > http://roscidus.com/blog/blog/2014/10/27/visualising-an-asynchronous= -monad/ > > 3. There is currently more debate than anyone could wish for around > a pull request of Mark Shinwell for runtime support for dynamic call > graph construction and its use for memory profiling. > https://github.com/ocaml/ocaml/pull/585 > > 4. Providing a good user experience for performance or space profiling > is a fundamentally harder problem than for GC pauses. It may > require specially-compiled versions of the libraries used by your > program, and thus a general policy/agreement across the > ecosystem. Swapping a different runtime at link-time is very easy. > > -- > 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