From mboxrd@z Thu Jan 1 00:00:00 1970 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 pB89D5Ag014517 for ; Thu, 8 Dec 2011 10:13:05 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuYBAE9/4E7U4xEIkGdsb2JhbABAAw6aKZAtIgEBAQEJCQ0HFAMigXIBAQQBbgsFCwUGJQgZRRIGEwkIAYd1Aga2fIN3hCAHgx0EjHQTFQGZPTg X-IronPort-AV: E=Sophos;i="4.71,319,1320620400"; d="scan'208";a="134498516" Received: from moutng.kundenserver.de ([212.227.17.8]) by mail1-smtp-roc.national.inria.fr with ESMTP; 08 Dec 2011 10:12:47 +0100 Received: from office1.lan.sumadev.de (dslb-188-097-005-129.pools.arcor-ip.net [188.97.5.129]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MB68W-1RQqGw3uI0-00ABaD; Thu, 08 Dec 2011 10:12:47 +0100 Received: from gps.dynxs.de (localhost [127.0.0.1]) by office1.lan.sumadev.de (Postfix) with ESMTP id 40CCEC00C7; Thu, 8 Dec 2011 10:12:46 +0100 (CET) Received: from 84.233.128.147 (SquirrelMail authenticated user gerd) by gps.dynxs.de with HTTP; Thu, 8 Dec 2011 10:12:46 +0100 Message-ID: In-Reply-To: References: Date: Thu, 8 Dec 2011 10:12:46 +0100 From: "Gerd Stolpmann" To: "William Le Ferrand" Cc: "caml users" User-Agent: SquirrelMail/1.4.21 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 (Normal) Importance: Normal X-Provags-ID: V02:K0:O8rFjI5uwlaCjguC2S3TAS/Ag39bskKo4Y4jIqDCW6a L3lOQsr4QTkADe6C/Awu3Ba1dDl0s0HHWsWZHD3DSlSfN6xpfW K9SNTyeYQT2Q4DUnerWLBtsQCOprqDzh8gFtru2giacA14Y2Qd GioIyY/0Aqp+dLyHv2kMHRksZu3hRW9bUrULp9UNGo4GuE3I5n rNU4hXj7EQtTfKkTgPY2NRSUEmsqNv1lMCGU5QgpEM0JdC4ZJG MNpDvygCbaBQA7AqBO9NhH4rEobzvPiF/zoNBuLliai0NPh0vS +zl6m/gX2kYHaMjEAw3nMqfSp1yZ3BHFBAjNwGtDhRPLdyBbO7 ES1ESi5kT6C2ZPzV7aCnTbWelOfNs2J2O8xqyJfwpuRnls0aPo /dFDX7oqzKtLw== Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id pB89D5Ag014517 Subject: Re: [Caml-list] Storing ocaml values outside ocaml's heap Hi William, this can be made working, and there is already a lot of support in Ocamlnet (module Netsys_mem, espeically init_value). I'm now using this all the time for populating shared memory blocks (which need to be outside the ocaml heap) with normal ocaml values. In Ocamlnet I'm using simply a bigarray for keeping the reference to the off-heap memory area (remember, bigarrays are just pointers to C arrays). This allows it to program the whole algorithm accessing such values in Ocaml. A warning though: Experience shows also that this type of programming is very error-prone, as you always have to take the memory representation of ocaml values into account. Gerd > 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/ > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > -- Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de *** Searching for new projects! Need consulting for system *** programming in Ocaml? Gerd Stolpmann can help you.