caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Neal Wang" <neal.wang@gmail.com>
To: "The Caml Trade" <caml-list@inria.fr>
Subject: Re: [Caml-list] Can GC be BLOCKed?
Date: Fri, 1 Dec 2006 10:53:08 -0800	[thread overview]
Message-ID: <1965df800612011053x1c442d31if3ef14c5f87ba76d@mail.gmail.com> (raw)
In-Reply-To: <20061201091932.GA29517@furbychan.cocan.org>

The problem is not caused by real-time requirement.
Let me explain it in more details:

1. a sqlite3 database is used store mutable objects (objects are
marshaled as strings and stored as BLOB in DB. The objects are very
large and have variant sizes)

2. Weak module is used to cache these objects.

3. Finalise function is used to write back the change of these in
memory objects into the sqlite3 database when GC is called.

The scheme follows  the example in section "Garbage collection" of
ocaml-tutorial.org.

The problem is that:
 When an object is being loaded through an "sql" select stmt, GC is
then invoked to reclaim memory which will in turn call finalise
functions to store some objects into db.  At this moment, the db has
been locked by the select stmt, and the storing procedure fails.  The
problem is due to sqlite3 doesn't provide row level locks.  A simple
solution is to prevent GC from calling finalise functions whenever we
are loading an object into memory.

IMHO, providing a way to disable GC will help a lot in variant
situations.  The only side effect of misuse such a feature is out of
memory exception which does happen even GC is always enabled.

Neal

On 12/1/06, Richard Jones <rich@annexia.org> wrote:
> On Thu, Nov 30, 2006 at 04:07:51PM -0800, Neal Wang wrote:
> > Thanks for your help.  But your solution only work for a function
> > which allocates
> >  memory of fixed size. Unfortunately, the atomic function, which
> > cannot be interrupted by GC, read input data from external channels
> > and the memory needed to store the input data is not determined ahead.
> > The official interface of GC doesn't not provide a  way to stop GC. Is
> > there a backdoor such that we can use to stop GC?
>
> I can't see how this would work.  The minor heap is a fixed size (32K
> or something) and when this is used up, you _have_ to do a minor
> collection.
>
> Can you tell us what the problem is that you're trying to solve?
>
> I've only seen two cases where I'd want to stop the GC from running:
> (1) During quasi real-time operations (eg. a single frame in a game) --
> this can be solved by making the heap large enough and running the GC
> at scheduled points.  (2) When the heap is larger than physical RAM --
> this is solved using our 'Ancient' module.
>
> Rich.
>
> --
> Richard Jones, CTO Merjis Ltd.
> Merjis - web marketing and technology - http://merjis.com
> Internet Marketing and AdWords courses - http://merjis.com/courses - NEW!
> Merjis blog - http://blog.merjis.com - NEW!
>


  parent reply	other threads:[~2006-12-01 18:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-30  0:33 Neal Wang
2006-11-30  3:07 ` [Caml-list] " James Woodyatt
2006-12-01  0:07   ` Neal Wang
2006-12-01  0:38     ` Tom
2006-12-01  9:19     ` Richard Jones
2006-12-01 13:39       ` Dmitry Bely
2006-12-01 23:28         ` Philippe Wang
2006-12-02 10:04           ` Dmitry Bely
2006-12-02 12:14             ` Philippe Wang
2006-12-02 11:19         ` Richard Jones
2006-12-01 18:53       ` Neal Wang [this message]
2006-12-01 19:13         ` Chris King
2006-12-04  9:37         ` Hendrik Tews

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=1965df800612011053x1c442d31if3ef14c5f87ba76d@mail.gmail.com \
    --to=neal.wang@gmail.com \
    --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).