caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus@mail4.ai.univie.ac.at>
To: Gregory Morrisett <jgm@cs.cornell.edu>
Cc: OCAML <caml-list@inria.fr>
Subject: Re: [Caml-list] "super-compaction" of values
Date: Thu, 2 Aug 2001 17:56:13 +0200	[thread overview]
Message-ID: <20010802175613.A16445@kastanie.ai.univie.ac.at> (raw)
In-Reply-To: <24C06C2959910949931A2337CB264DCB052044@opus.cs.cornell.edu>; from jgm@cs.cornell.edu on Thu, Aug 02, 2001 at 09:28:04 -0400

On Thu, 02 Aug 2001, Gregory Morrisett wrote:
> Similarly, Zhong Shao's Flint IL uses hash-consing for type terms
> quite effectively.  I can dig up the reference if you like.  In
> these two settings, one has to worry about the exponential blow
> up you can get by turning a DAG into a tree.

This is not a problem for me, because the trees really stay trees (as
datastructure), only that OCaml will represent them as DAGs in memory
after the transformation. Of course, if you want to print such a tree,
you'll have to cut exponentially many trees for the paper ;)

So there are really two kinds of DAGs: the explicitly constructed one that
uses (integer) indices to refer to subtrees, and the "normal" tree, which
uses sharing. Unfortunately, I can't use the sharing-tree representation
with memory addresses as indices alone, because the GC can move things,
which destroys any kind of order relation based on memory addresses to
search for matching subtrees... :(

> In addition, the hash-consing made structural equality tests quite cheap
> (O(1)) which is important for type checking or proof verification.

Well, one has to "hash-cons" a freshly generated tree at least once,
but then one can find equivalent (sub)trees very fast, because they'll be
pointer-equal. If they aren't, they cannot be structurally equivalent. The
algorithm I have in mind shouldn't require more than O(n*log(n)) time
(n being the number of nodes in the tree) for merging a fresh tree into
the hash-consing datastructure. Hm, let's see...

> For TAL, GC was not an issue, though we thought it might be.  For Flint,
> if memory serves, they periodically flushed the table or used some
> finalization/weak-pointer tricks.

In the first attempt I'll probably use "manual" removing of unneeded
trees from the hash-consing datastructure. Maybe then I'll play some
finalization tricks that remove unreachable trees automatically, only
leaving subtrees shared with not yet removed trees.

Thanks to all of you for your numerous answers!

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2001-08-02 15:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-02 13:46 Dave Berry
2001-08-02 13:28 ` Gregory Morrisett
2001-08-02 15:56   ` Markus Mottl [this message]
     [not found] <200108011606.JAA29019@dhpc0010.pdx.intel.com>
2001-08-02  9:42 ` Markus Mottl
  -- strict thread matches above, loose matches on Subject: below --
2001-08-01 13:12 Damien Doligez
2001-08-01 10:20 Markus Mottl
2001-08-01 13:41 ` Thorsten Ohl
2001-08-01 14:09   ` Markus Mottl
2001-08-01 14:29     ` Thorsten Ohl
2001-08-01 15:25       ` Markus Mottl
2001-08-02  1:48 ` Alexander V. Voinov

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=20010802175613.A16445@kastanie.ai.univie.ac.at \
    --to=markus@mail4.ai.univie.ac.at \
    --cc=caml-list@inria.fr \
    --cc=jgm@cs.cornell.edu \
    /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).