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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 6B0587EC41 for ; Wed, 24 Oct 2012 19:23:20 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of martin.jambon@ens-lyon.org) identity=pra; client-ip=66.111.4.28; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="martin.jambon@ens-lyon.org"; x-sender="martin.jambon@ens-lyon.org"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of martin.jambon@ens-lyon.org) identity=mailfrom; client-ip=66.111.4.28; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="martin.jambon@ens-lyon.org"; x-sender="martin.jambon@ens-lyon.org"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@out4-smtp.messagingengine.com) identity=helo; client-ip=66.111.4.28; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="martin.jambon@ens-lyon.org"; x-sender="postmaster@out4-smtp.messagingengine.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At0AAL8iiFBCbwQckWdsb2JhbABEr2+SCiMBAQEBCQsLBxQEI4IeAQEEAScRCC4KAgQLCxgJBBIPCQMCAQIBMxITBgIBAQ6HYAMJBgupDIQ5hU8DiVgGi2GGbYhfji6ETY1k X-IronPort-AV: E=Sophos;i="4.80,640,1344204000"; d="scan'208";a="178779049" Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 24 Oct 2012 19:23:19 +0200 Received: from compute6.internal (compute6.nyi.mail.srv.osa [10.202.2.46]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 72FDD20848 for ; Wed, 24 Oct 2012 13:23:18 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute6.internal (MEProxy); Wed, 24 Oct 2012 13:23:18 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=ZldSHGmzxS5U/ZjRMDiG2h 1gKSM=; b=WIoYcHwsJrtzrPFP3Hti1enjWLLfb4zoFodgcKuKDe4jEiTG5UoMge a/jV8fK7p66prrRVJvp0IjDFN6h3/d+4hc443rgVZuY0Rd+hDVjQ3vrMTILq9vq+ Cklca7shi7kYCWpfnfd3kA7U4NsniYvw4/KkFSoYTEQAYUwfNZ1nI= X-Sasl-enc: JtG1UejxuN+b3RiKkMc9TmuG4UYTfr2jWHjkZoKFCaex 1351099398 Received: from [192.168.1.127] (unknown [50.76.32.210]) by mail.messagingengine.com (Postfix) with ESMTPA id 0D19B482611 for ; Wed, 24 Oct 2012 13:23:17 -0400 (EDT) Message-ID: <50882404.2030106@ens-lyon.org> Date: Wed, 24 Oct 2012 10:23:16 -0700 From: Martin Jambon User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: caml-list@inria.fr References: <1351094857.12207.12@samsung> In-Reply-To: <1351094857.12207.12@samsung> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: AW: [Caml-list] Behaviour of an OCaml program: any possible GC improvement? On 10/24/2012 09:07 AM, Gerd Stolpmann wrote: > I don't think you can do much here by just setting parameters. (Btw., > there is no need to compile the mli's with -p.) > > I've seen high CPU for garbage collection frequently for mainly > functional programs. It's their nature - you generate lots of > short-living intermediate results. You can change that only by changing > the algorithm, e.g. by caching results that would otherwise be > recomputed again. Some improvement is also possible with simple tricks, > e.g. if you have something like > > Number 0 > > where Number is from an algebraic type, and you use this term > frequently, consider to add a constant for it, > > let n0 = Number 0 > > so this isn't reallocated all the time (even: if n=0 then n0 else Number > n). If this term is used often, this makes a noticeable difference. Note that the following works too: if n = 0 then Number 0 (* structured constant *) else Number n # type t = Number of int;; type t = Number of int # let f () = Number 0;; val f : unit -> t = # f () == f ();; - : bool = true Martin > Am 24.10.2012 17:09:12 schrieb(en) David MENTRE: >> Hello, >> >> 2012/10/24 David MENTRE : >> > But, after recompiling everything from scratch and redoing my tests >> > (taking care of erasing old gmon.out file), I have the same result >> > (with calling caml_call_gc). :-( >> >> For the sake of completeness, I installed latest OCaml 4.00.1 (for the >> recall, Linux x86_64 platform), recompiled everything from scratch and >> re-did my tests. I obtain roughly the same results and the same >> calling caml_call_gc. :-( >> >> There should be something obvious that I missed. >> >> """ >> Flat profile: >> >> Each sample counts as 0.01 seconds. >> % cumulative self self total >> time seconds seconds calls s/call s/call name >> 32.54 155.97 155.97 35791 0.00 0.01 mark_slice >> 19.87 251.24 95.26 58230 0.00 0.00 sweep_slice >> 12.35 310.42 59.18 88113 0.00 0.00 camlMap__map_1150 >> 6.66 342.34 31.92 94021 0.00 0.00 caml_oldify_mopup >> 6.57 373.81 31.47 1986040761 0.00 0.00 >> caml_page_table_lookup >> 4.66 396.17 22.36 3792214394 0.00 0.00 caml_fl_allocate >> 4.33 416.94 20.77 3799622226 0.00 0.00 caml_oldify_one >> 3.39 433.18 16.24 3873315118 0.00 0.00 >> caml_fl_merge_block >> 2.51 445.20 12.03 3792214239 0.00 0.00 caml_alloc_shr >> 1.38 451.83 6.63 3882908903 0.00 0.00 >> camlData_typing__apply_1255 >> 1.26 457.88 6.05 3792214239 0.00 0.00 allocate_block >> 1.20 463.62 5.74 1 5.74 5.74 >> caml_realloc_ref_table >> 0.49 465.99 2.37 188042 0.00 0.00 clear_table >> 0.44 468.09 2.10 3881730105 0.00 0.00 >> camlData_typing__fun_1445 >> 0.42 470.08 1.99 caml_fl_reset >> 0.31 471.57 1.50 >> caml_set_allocation_policy >> 0.28 472.90 1.33 896098 0.00 0.00 caml_gc_message >> 0.24 474.06 1.16 74 0.02 0.02 camlMap__iter_1144 >> 0.22 475.12 1.06 155 0.01 0.01 caml_add_to_heap >> 0.11 475.64 0.53 >> camlData_typing__fun_1430 >> 0.07 475.98 0.34 >> camlData_typing__print_vset_1115 >> 0.06 476.29 0.31 94021 0.00 0.00 >> caml_oldify_local_roots >> 0.04 476.46 0.17 10355866 0.00 0.00 >> camlFormat__doprn_1525 >> 0.03 476.61 0.15 95566109 0.00 0.00 caml_modify >> 0.03 476.74 0.13 5946696 0.00 0.00 >> camlFormat__kpr_1514 >> 0.03 476.86 0.12 10179867 0.00 0.00 >> camlFormat__advance_loop_1173 >> 0.02 476.97 0.11 16452591 0.00 0.00 >> camlFormat__format_pp_token_1134 >> 0.02 477.05 0.08 15459066 0.00 0.00 caml_putblock >> 0.02 477.13 0.08 16452612 0.00 0.00 >> camlFormat__add_queue_1087 >> [...] >> granularity: each sample hit covers 2 byte(s) for 0.00% of 479.32 seconds >> >> index % time self children called name >> 0.00 0.11 25/94021 caml_alloc_small [75] >> 0.00 0.56 133/94021 caml_alloc_string [51] >> 0.02 394.48 93863/94021 >> caml_garbage_collection [3] >> [1] 82.4 0.02 395.15 94021 caml_minor_collection [1] >> 0.02 297.93 94021/94021 >> caml_major_collection_slice [4] >> 0.01 97.19 188042/188042 caml_empty_minor_heap >> [7] >> 0.00 0.00 94021/94021 caml_final_do_calls >> [353] >> ----------------------------------------------- >> >> [2] 82.3 0.04 394.50 caml_call_gc [2] >> 0.00 394.50 93863/93863 >> caml_garbage_collection [3] >> ----------------------------------------------- >> 0.00 394.50 93863/93863 caml_call_gc [2] >> [3] 82.3 0.00 394.50 93863 caml_garbage_collection [3] >> 0.02 394.48 93863/94021 caml_minor_collection >> [1] >> 0.00 0.00 93863/97401 >> caml_process_pending_signals [352] >> ----------------------------------------------- >> 0.02 297.93 94021/94021 caml_minor_collection >> [1] >> [4] 62.2 0.02 297.93 94021 >> caml_major_collection_slice [4] >> 155.97 29.41 35791/35791 mark_slice [5] >> 95.26 16.33 58230/58230 sweep_slice [6] >> 0.84 0.00 564126/896098 caml_gc_message [43] >> 0.00 0.10 4652/4652 start_cycle [76] >> 0.00 0.01 4651/4651 >> caml_compact_heap_maybe [135] >> ----------------------------------------------- >> 155.97 29.41 35791/35791 >> caml_major_collection_slice [4] >> [5] 38.7 155.97 29.41 35791 mark_slice [5] >> 29.31 0.00 1849494323/1986040761 >> caml_page_table_lookup [16] >> 0.11 0.00 71582/896098 caml_gc_message [43] >> 0.00 0.00 1/1 realloc_gray_vals [269] >> 0.00 0.00 4652/4652 caml_final_update [377] >> 0.00 0.00 4652/4653 caml_fl_init_merge [375] >> ----------------------------------------------- >> 95.26 16.33 58230/58230 >> caml_major_collection_slice [4] >> [6] 23.3 95.26 16.33 58230 sweep_slice [6] >> 16.24 0.00 3873315117/3873315118 >> caml_fl_merge_block [18] >> 0.09 0.00 58230/896098 caml_gc_message [43] >> 0.00 0.00 1/1 caml_finalize_channel >> [477] >> ----------------------------------------------- >> 0.01 97.19 188042/188042 caml_minor_collection >> [1] >> [7] 20.3 0.01 97.19 188042 caml_empty_minor_heap [7] >> 31.92 62.08 94021/94021 caml_oldify_mopup [8] >> 2.37 0.00 188042/188042 clear_table [29] >> 0.31 0.07 94021/94021 >> caml_oldify_local_roots [58] >> 0.28 0.00 188042/896098 caml_gc_message [43] >> 0.05 0.10 9383144/3799622226 caml_oldify_one [14] >> 0.00 0.00 188042/188042 >> caml_final_empty_young [344] >> ----------------------------------------------- >> 31.92 62.08 94021/94021 caml_empty_minor_heap >> [7] >> [8] 19.6 31.92 62.08 94021 caml_oldify_mopup [8] >> 20.71 41.37 3787931806/3799622226 caml_oldify_one >> [14] >> ----------------------------------------------- >> [...] >> """ >> >> Best regards, >> david >> >> -- >> 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 >> >> >