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 9D80ABBAF for ; Thu, 11 Nov 2010 10:08:10 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkkEAANB20zZSMDdX2dsb2JhbACiPwsXCQoaAx+/aYVKBI1jiAo X-IronPort-AV: E=Sophos;i="4.59,181,1288566000"; d="scan'208";a="65466089" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Nov 2010 10:08:10 +0100 Received: from smtp08.web.de ( [172.20.5.216]) by fmmailgate01.web.de (Postfix) with ESMTP id 767FF17764163; Thu, 11 Nov 2010 10:08:09 +0100 (CET) Received: from [78.43.204.177] (helo=frosties.localdomain) by smtp08.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #24) id 1PGT8b-0008VA-00; Thu, 11 Nov 2010 10:08:09 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.72) (envelope-from ) id 1PGT8b-0002cd-1B; Thu, 11 Nov 2010 10:08:09 +0100 From: Goswin von Brederlow To: Jianzhou Zhao Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Average cost of the OCaml GC References: Date: Thu, 11 Nov 2010 10:08:08 +0100 In-Reply-To: (Jianzhou Zhao's message of "Wed, 10 Nov 2010 22:59:55 -0500") Message-ID: <87bp5w1b47.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1+rQjKDuvShYcG/JIV+HPEdCf8KEvFV1WMwUpyR wN6vzLZ3we5NWxNCqdLtxNpMIQ9y1rgHyfRJnbP1ZHUhOfXwIB rPnBbRO2o= X-Spam: no; 0.00; ocaml:01 ocaml:01 'self:01 'self:01 alloc:01 zhao:98 57%:98 57%:98 mfg:98 upenn:01 caml-list:01 functions:01 functions:01 writes:01 data:02 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' and 'sweep_slice' are 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. If you set them wrong you might trigger the GC too often. MfG Goswin