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 4281E820A1 for ; Fri, 6 Sep 2013 11:26:17 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of berenger@riken.jp) identity=pra; client-ip=134.160.33.162; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="berenger@riken.jp"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of berenger@riken.jp designates 134.160.33.162 as permitted sender) identity=mailfrom; client-ip=134.160.33.162; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="berenger@riken.jp"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@postman.riken.jp designates 134.160.33.162 as permitted sender) identity=helo; client-ip=134.160.33.162; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="postmaster@postman.riken.jp"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmQBAEGfKVKGoCGinGdsb2JhbABbgzyvXpJEgTgOAQEBAQEGDQkJFCiCJAEBBAE4NgoRCwcRCQQSDwkDAgECATMSEwYCAQEOh14DCQYMtQIDiSePeRaEBwOJM45CgS+EfY5p X-IPAS-Result: AmQBAEGfKVKGoCGinGdsb2JhbABbgzyvXpJEgTgOAQEBAQEGDQkJFCiCJAEBBAE4NgoRCwcRCQQSDwkDAgECATMSEwYCAQEOh14DCQYMtQIDiSePeRaEBwOJM45CgS+EfY5p X-IronPort-AV: E=Sophos;i="4.90,853,1371074400"; d="scan'208";a="31757847" Received: from postman2.riken.jp (HELO postman.riken.jp) ([134.160.33.162]) by mail2-smtp-roc.national.inria.fr with ESMTP; 06 Sep 2013 11:26:14 +0200 Received: from postman.riken.jp (postman2.riken.jp [127.0.0.1]) by postman.riken.jp (Postfix) with SMTP id 18DFF1260327 for ; Fri, 6 Sep 2013 18:26:12 +0900 (JST) Received: from [172.27.98.103] (rikad98.riken.jp [134.160.214.98]) by postman.riken.jp (Postfix) with ESMTPA id 050561270051 for ; Fri, 6 Sep 2013 18:26:11 +0900 (JST) Message-ID: <52299FA9.4030104@riken.jp> Date: Fri, 06 Sep 2013 18:26:01 +0900 From: Francois Berenger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: caml-list@inria.fr References: <52293459.9060707@riken.jp> <5229923B.6090404@coherentgraphics.co.uk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.9.6.92119 Subject: Re: [Caml-list] an OCaml program profile For the record, I replaced a function using a list and a hash table by a function using a float array. Since the culprit function is a numerical algorithm, that's probably what I should have done from the beginning. The program is way faster now. On 09/06/2013 05:49 PM, Gabriel Scherer wrote: > I have found the "poor man profiler" approach to work well when you > want to know not only which functions calls some slow runtime function > the most, but only in which situation (it depends on the callstack and > not only the source location). Ygrek's pmpa script is very helpful for > that > http://ygrek.org.ua/p/code/pmpa > > > On Fri, Sep 6, 2013 at 10:28 AM, John Whitington > wrote: >> Hi, >> >> >> Francois Berenger wrote: >>> >>> Hello, >>> >>> I am running experiments with a program. >>> I'd like the program to run faster because >>> it would reduce experiments round-trip. >>> >>> Here is the top of the profile: >>> --- >>> Flat profile: >>> >>> Each sample counts as 0.01 seconds. >>> % cumulative self self total >>> time seconds seconds calls s/call s/call name >>> 58.07 132.13 132.13 161527987 0.00 0.00 caml_fl_allocate >>> 21.13 180.21 48.08 2339 0.02 0.02 caml_fl_add_blocks >>> 4.87 191.30 11.09 5497 0.00 0.00 mark_slice >>> 1.65 195.06 3.76 979591485 0.00 0.00 caml_page_table_lookup >>> 1.50 198.47 3.41 5620 0.00 0.00 sweep_slice >>> 1.20 201.21 2.74 186584504 0.00 0.00 caml_oldify_one >>> 1.04 203.57 2.36 134849325 0.00 0.00 compare_val >>> 1.02 205.89 2.32 290049921 0.00 0.00 caml_float_compare >>> 0.80 207.71 1.82 123048730 0.00 0.00 caml_hash >>> 0.76 209.44 1.73 161525648 0.00 0.00 caml_alloc_shr >>> --- >>> >>> I think the program spends most of its time doing garbage >>> collection. >>> >>> How can I make it go faster? >> >> >> Look further down the profile in the individual numbered sections for each >> function. The section for "caml_call_gc" usually provides the most useful >> start. >> >> For example, if most calls to caml_call_gc are from List.rev, look at calls >> to that etc. It's not entirely straightforward, but after a bit of following >> numbers around the file, you'll get used to it. >> >> Thanks, >> >> -- >> John Whitington >> Director, Coherent Graphics Ltd >> http://www.coherentpdf.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 >