From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id DF4C5BBAF for ; Thu, 11 Nov 2010 14:52:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlsBAM+D20xKfVIukGdsb2JhbACiOQgVAQEBAQkJDAcRAx+leYt4hUIjiGQBAQMFhUUEhFqFfoko X-IronPort-AV: E=Sophos;i="4.59,183,1288566000"; d="scan'208";a="65479882" Received: from mail-ww0-f46.google.com ([74.125.82.46]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Nov 2010 14:52:46 +0100 Received: by wwj40 with SMTP id 40so57473wwj.3 for ; Thu, 11 Nov 2010 05:52:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=iJ2d9vEXe/aCwbQfr/34AWqlHzONs3hbLqejWVqAsvA=; b=GZTl138Es4e4zSHAYvikNX4hq/em8hjiCT347hcD+ZV25qgV6uC2yR/G1/UKN9VR1b WH8eWVBlYvrPMgo6fu79J17YXxVoJYonz6y1pJ37SVye6rz2fKwa4lIdwYIcb9UvCIPk Gin7/gWEPAipniXf1LlOgeV6PbIUnnhBhciGM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=ZsiaPO5q85Cu0dvi4Uf4FqFbcQlkGIIH6e1ODgwvXwguIssuIO4na4UxewrKx8HXV1 afG2YdNPfqNba6CKiQnHgUauhZFp9Ls4u0VgfEyznxLhUahwGEAIBqj/GMVLg/AMRaTA ADB8lzoo1WeyQGMvw+KQQjmWgxucZ0/ixy/jI= MIME-Version: 1.0 Received: by 10.216.18.71 with SMTP id k49mr701726wek.67.1289483565501; Thu, 11 Nov 2010 05:52:45 -0800 (PST) Sender: jianzhou.zh@gmail.com Received: by 10.216.239.132 with HTTP; Thu, 11 Nov 2010 05:52:45 -0800 (PST) In-Reply-To: <87bp5w1b47.fsf@frosties.localnet> References: <87bp5w1b47.fsf@frosties.localnet> Date: Thu, 11 Nov 2010 08:52:45 -0500 X-Google-Sender-Auth: Giygzgsmj2bCx3nEm5vktLo7-PU Message-ID: Subject: Re: [Caml-list] Average cost of the OCaml GC From: Jianzhou Zhao To: Goswin von Brederlow Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; ocaml:01 ocaml:01 'self:01 'self:01 alloc:01 alloc:01 pointers:01 'as:01 zhao:98 zhao:98 57%:98 57%:98 mfg:98 wrote:01 upenn:01 On Thu, Nov 11, 2010 at 4:08 AM, Goswin von Brederlow w= rote: > Jianzhou Zhao writes: > >> Hi, >> >> What is the average cost of the OCaml GC? I have a program that calls >> 'mark_slice' in 57% of the total execution time, and calls >> 'sweep_slice' in 21% of the total time, reported by Callgrind, which >> is a profiling tool in Valgrind. 57% and 21% are the 'self cost' --- >> the cost of the function itself ('Self Cost'), rather than the cost >> including all called functions ('Inclusive Cost'). I guess >> 'mark_slice' =A0and =A0'sweep_slice' =A0are functions from OCaml GC. Are >> these numbers normal? > > Those numbers sound rather high to me. > >> My program calls both OCaml and C, which passes around C data types in >> between. I also doubt if I defined the interface in an 'unefficient' >> way that slows down the GC. Are there any rules in mind to make GC >> work more efficiently? > > You can tune some of the GC parameters to suit your use case. > > Do you allocate custom types from C? In caml_alloc_custom(ops, size, > used, max) the used and max do influence the GC how often to run. Yes. The code uses caml_alloc_custom to create a lot of small objects (less then 8 bytes) frequently. The used and max are set to be default, 0 and 1. The manual says http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc140 ///////////////////// If your finalized blocks contain no pointers to out-of-heap resources, or if the previous discussion made little sense to you, just take used =3D 0 and max =3D 1. But if you later find that the finalization functions are not called =93often enough=94, consider increasing the used / max ratio. ////////////////////// Does this mean the default used and max let GC do finalization 'as slow as possible'? This does not seem to be the case if the costs 57% and 20% are too high. > If you set them wrong you might trigger the GC too often. In which case could they be set 'wrong'? For example, if 'used' is not equal to the real amount of allocated data; or is there a range of 'max' given a used? > > MfG > =A0 =A0 =A0 =A0Goswin > --=20 Jianzhou