From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pB84ZvMg004043 for ; Thu, 8 Dec 2011 05:35:57 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsAKADQ+4E7RVdK2kWdsb2JhbABAA5o8LYdkAYZqF4ECCCIBAQEBCQkNBxInggsCLAE5Aw0FCQddEgEFASI1h22XI4JcCo5PhE0wiH4CBQyIC4MdBIgujD2Nbz2BS4JN X-IronPort-AV: E=Sophos;i="4.71,318,1320620400"; d="scan'208";a="122517416" Received: from mail-iy0-f182.google.com ([209.85.210.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 08 Dec 2011 05:35:51 +0100 Received: by iafi7 with SMTP id i7so3140138iaf.27 for ; Wed, 07 Dec 2011 20:35:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type; bh=tj1GS/R7VhSBsCx3qv66soCRdM4l1OTpqQpkhAMwb8M=; b=Re0pGdB4QpEqv+ZueigFgoNU1Owpxf40lYPg6F8pJ25VX8NGDwL5OfNNEZicT1t/xd roMzB6TL/W8P+3feIxkRJl2ASL6tctKsBDV1IZRqYSI9eW523UacA/V2X40M6Lw7mpxd O3SFUcBHAOKMmR6A7cYC/A3BoVpVTmSMj0HvI= Received: by 10.42.202.17 with SMTP id fc17mr1967566icb.15.1323318950197; Wed, 07 Dec 2011 20:35:50 -0800 (PST) MIME-Version: 1.0 Sender: warnegia@gmail.com Received: by 10.50.79.8 with HTTP; Wed, 7 Dec 2011 20:35:29 -0800 (PST) From: William Le Ferrand Date: Wed, 7 Dec 2011 20:35:29 -0800 X-Google-Sender-Auth: 1IfjDi1PIF5kkvzjOazpVG_bmec Message-ID: To: caml users Content-Type: multipart/alternative; boundary=20cf3010e71ff37b7a04b38d3338 Subject: [Caml-list] Storing ocaml values outside ocaml's heap --20cf3010e71ff37b7a04b38d3338 Content-Type: text/plain; charset=ISO-8859-1 Dear list, We are building a cache in ocaml and we're wondering if it would make sense to store ocaml values outside the reach of the gc. (gc on a 20GB cache hangs the process for a second or so). To run some experiments, we wrote a small library ( https://github.com/besport/ocaml-everlasting) that exposes two functions, get and set. When inserting a value, we copy recursively the blocs outside of the reach of the gc (and put the resulting value in some C array). When getting the value, we simply pass the pointer to the copied value to the ocaml code (the structure is still coherent and the value is directly usable). We also wrote an "update" function that compare a new value with the existing value in cache, to avoid unnecessary memory allocation/deallocation. It does not seems very stable though, but I don't know if it is a bug in the update function or simply because this approach is not reasonable. Do you have any thoughts? Is there any clever way to build a large cache in an ocaml app ? Thanks in advance for any tips! Best William -- William Le Ferrand Mobile : (+1) (415) 683-1484 Web : http://williamleferrand.github.com/ --20cf3010e71ff37b7a04b38d3338 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Dear list,=A0

We are building a cache in ocaml and we= 9;re wondering if it would make sense to store ocaml values outside the rea= ch of the gc. (gc on a 20GB cache hangs the process for a second or so).

To run some experiments, we wrote a small library (https://github.com/bes= port/ocaml-everlasting) that exposes two functions, get and set.=A0

When inserting a value, we copy recursively the blocs o= utside of the reach of the gc (and put the resulting value in some C array)= . When getting the value, we simply pass the pointer to the copied value to= the ocaml code (the structure is still coherent and the value is directly = usable). We also wrote an "update" function that compare a new va= lue with the existing value in cache, to avoid unnecessary memory allocatio= n/deallocation.

It does not seems very stable though, but I don't k= now if it is a bug in the update function or simply because this approach i= s not reasonable. Do you have any thoughts? Is there any clever way to buil= d a large cache in an ocaml app ?=A0

Thanks in advance for any tips!

Best

William


<= /div>--
William Le Ferrand

Mobile :=A0(+1)=A0(415) 683-1484

--20cf3010e71ff37b7a04b38d3338--