From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.1 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, HTML_MESSAGE,INFO_TLD,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id B02E1BC68 for ; Wed, 25 Oct 2006 20:21:17 +0200 (CEST) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.238]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id k9PILGfP016907 for ; Wed, 25 Oct 2006 20:21:17 +0200 Received: by wx-out-0506.google.com with SMTP id s7so188323wxc for ; Wed, 25 Oct 2006 11:21:14 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=J0GERjIQgUNClchlUl4I8K7ddKjLJxK1wiGPqP9yjDzrzeHM08PZpZFDZLau/SermS9OLVdt6mHGcBjNmVeRRY7ppQBk2zEMwnacpqf3QnuFcgWJ0Mh9WcmeDCK4lEdLTg3xZDp71MqLf08BuAUjzC6+qDnmetlrNjM6LWULWLo= Received: by 10.70.95.19 with SMTP id s19mr1502617wxb; Wed, 25 Oct 2006 11:21:14 -0700 (PDT) Received: by 10.70.16.10 with HTTP; Wed, 25 Oct 2006 11:21:14 -0700 (PDT) Message-ID: Date: Wed, 25 Oct 2006 14:21:14 -0400 From: "Markus Mottl" To: "Hendrik Tews" Subject: Re: [Caml-list] caml_oldify_local_roots takes 50% of the total runtime Cc: caml-list@inria.fr In-Reply-To: <17727.34685.561877.977822@tandem.cs.ru.nl> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_23075_18301663.1161800474748" References: <17727.34685.561877.977822@tandem.cs.ru.nl> X-j-chkmail-Score: MSGID : 453FAB1C.001 on discorde : j-chkmail score : X : 0/20 1 X-Miltered: at discorde with ID 453FAB1C.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; markus:01 mottl:01 markus:01 mottl:01 oldify:01 runtime:01 hendrik:01 tews:01 tews:01 damien:01 ocaml:01 node:01 pointers:01 ocaml:01 oldify:01 ------=_Part_23075_18301663.1161800474748 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, On 10/25/06, Hendrik Tews wrote: > > >From the comments of Damien Doligez in a related thread in > > http://caml.inria.fr/pub/ml-archives/caml-list/2004/07/84cd291931627c13faf56a259026885c.en.html > I got the impression that there is extra punishment for > caml_local_roots. Should the situation improve if I organize the > 350.000 ocaml node pointers on the ocaml side via one local root > (asumming this information is needed not so often)? > This is a known problem: the OCaml-runtime calls this function (caml_oldify_local_roots) at each minor collection. The function iterates over all local roots, and since minor collections happen quite often, this naturally leads to excessive CPU-usage - even if hardly anything else is going on. To work around this problem you should store pointers to the C++-objects on the C++-side, and e.g. associate them with finalized OCaml-values, or handles which allow you to explicitly deallocate the objects. It would be great if the GC could be improved in situations where there are many local roots. This is a pretty common problem when interfacing non-trivial third party libraries, and the clumsy workarounds require writing somewhat error-prone code. Best regards, Markus -- Markus Mottl http://www.ocaml.info markus.mottl@gmail.com ------=_Part_23075_18301663.1161800474748 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi,

On 10/25/06, Hendrik Tews <H.Tews@cs.ru.nl> wrote:
>From the comments of Damien Doligez in a related thread in
http://caml.inria.fr/pub/ml-archives/caml-list/2004/07/84cd291931627c13faf56a259026885c.en.html
I got the impression that there is extra punishment for
caml_local_roots. Should the situation improve if I organize the
350.000 ocaml node pointers on the ocaml side via one local root
(asumming this information is needed not so often)?

This is a known problem: the OCaml-runtime calls this function (caml_oldify_local_roots) at each minor collection.  The function iterates over all local roots, and since minor collections happen quite often, this naturally leads to excessive CPU-usage - even if hardly anything else is going on.

To work around this problem you should store pointers to the C++-objects on the C++-side, and e.g. associate them with finalized OCaml-values, or handles which allow you to explicitly deallocate the objects.

It would be great if the GC could be improved in situations where there are many local roots.  This is a pretty common problem when interfacing non-trivial third party libraries, and the clumsy workarounds require writing somewhat error-prone code.

Best regards,
Markus

--
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com ------=_Part_23075_18301663.1161800474748--