caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Gerd Stolpmann" <info@gerd-stolpmann.de>
To: "William Le Ferrand" <William.Le-Ferrand@polytechnique.edu>
Cc: "caml users" <caml-list@inria.fr>
Subject: Re: [Caml-list] Storing ocaml values outside ocaml's heap
Date: Thu, 8 Dec 2011 10:12:46 +0100	[thread overview]
Message-ID: <fcd165b02501a02323f6b2f509a778ef.squirrel@gps.dynxs.de> (raw)
In-Reply-To: <CAGS5m-=5CvbV+V9Bu4XVYaRj_jy0E4-u1Vg1oGgZLGRrA=89Lw@mail.gmail.com>

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/
> <http://www.linkedin.com/in/williamleferrand>
>
> --
> 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.



  parent reply	other threads:[~2011-12-08  9:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-08  4:35 William Le Ferrand
2011-12-08  6:04 ` Stéphane Glondu
2011-12-08  8:19   ` William Le Ferrand
2011-12-08  9:04     ` Anil Madhavapeddy
2011-12-08  9:07       ` William Le Ferrand
2011-12-08 11:03       ` oliver
2011-12-08 17:02         ` Goswin von Brederlow
2011-12-08  9:40   ` Gaius Hammond
2011-12-08  8:49 ` Anders Fugmann
2011-12-08  8:56   ` William Le Ferrand
2011-12-08  9:29     ` Anders Fugmann
2011-12-08  9:12 ` Gerd Stolpmann [this message]
2011-12-08 10:33 ` Goswin von Brederlow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fcd165b02501a02323f6b2f509a778ef.squirrel@gps.dynxs.de \
    --to=info@gerd-stolpmann.de \
    --cc=William.Le-Ferrand@polytechnique.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).