From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pB88oVkd012441 for ; Thu, 8 Dec 2011 09:50:31 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4EACN54E5auLfF/2dsb2JhbABAAw6rW4FyAQEFOEABEAsYCRYPCQMCAQIBRQYNAQcCiAUGtneIHoMdBJo2jCQ4 X-IronPort-AV: E=Sophos;i="4.71,319,1320620400"; d="scan'208";a="134494419" Received: from 0405ds1-vaer.0.fullrate.dk (HELO fw.fugmann.net) ([90.184.183.197]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 08 Dec 2011 09:50:29 +0100 Received: from [10.0.10.34] (unknown [195.184.103.10]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by fw.fugmann.net (Postfix) with ESMTPSA id 5331A40061; Thu, 8 Dec 2011 09:50:28 +0100 (CET) Message-ID: <4EE07A30.4090000@fugmann.net> Date: Thu, 08 Dec 2011 09:49:52 +0100 From: Anders Fugmann User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20111010 Iceowl/1.0b2 Icedove/3.1.15 MIME-Version: 1.0 To: William Le Ferrand CC: caml users References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Validation-by: af@issuu.com Subject: Re: [Caml-list] Storing ocaml values outside ocaml's heap Hi William, Have you tried netshm from ocamlnet library? It seems that it would fit your requirements by placing memory outside the reach of the garbage collector. Using netshm would require a lot of serialization / deserilization and memory copying, which might not be that efficient if you access the cache a lot. Regards Anders Fugmann On 12/08/2011 05:35 AM, William Le Ferrand wrote: > 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/ > >