unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludovic.courtes@laas.fr (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] Marking weak alist vectors
Date: Wed, 09 Nov 2005 17:28:01 +0100	[thread overview]
Message-ID: <87y83xkcq6.fsf@laas.fr> (raw)
In-Reply-To: <4371CF46.4010708@xs4all.nl> (Han-Wen Nienhuys's message of "Wed,  09 Nov 2005 11:28:22 +0100")

Han-Wen Nienhuys <hanwen@xs4all.nl> writes:

> Does your patch solve the problem that cyclical structures (values that 
> point back to keys) should also be GC-ed?

I guess you're talking about cyclical structures in doubly-weak alist
vectors.  If so, it apparently does since if both WEAK_VALUES and
WEAK_KEYS are false in both functions, then neither the key nor the
value will ever be marked by those functions.

Actually, I've spent some time re-reviewing this patch and I'm having
starting to have a headache.  But anyway, here are a few thoughts.

1.  The tests in `weaks.test' are broken in several ways, not only
    because "we have no way of knowing for certain that the object is
    really dead" as stated there.

    * First, they assume that

        (begin
          (hashq-set! h "a string" 123)
          (hashq-ref  h "a string))

      returns true.  This is wrong since `hashq-ref' uses `eq?' to
      compare keys, and `(eq? "a string" "a string")' returns #f.
      Instead, it could use `hash-map->list'.

    * Second, it should perform a `(read-disable 'positions)' since
      source properties rely on a weakly-keyed hash table where keys are
      source expressions.

2.  The C test I submitted, unlike `weaks.test', can *reliably*
    determine whether an object was swept.  However, it is clearly not
    as complete as `weaks.test'.

3.  Given the level of non-determinism I've been able to observe, I'm
    afraid leaks are causing us difficulties.  For instance, while
    testing weakly-key alist vectors "by hand" in a REPL, it occurred to
    me that the weak-key pair would reliably die, *unless* the hash
    table was written (I mean using `write'):

      guile> (define h (make-doubly-weak-alist-vector 12))
      guile> (hashq-set! h "sdf" "paf")
      guile> (hashq-set! h "hello" "world")
      guile> (gc)
      guile> h
      #w(() () () () () () () () () () () ())

    The same but print H before calling `gc':

      guile> (hashq-set! h "sdf" "paf")
      guile> (hashq-set! h "hello" "world")
      guile> h
      #w((("hello" . "world") ("sdf" . "paf")) () () () () () () () () () () ())
      guile> (gc)
      guile> (gc)
      guile> (gc)
      guile> h
      #w((("hello" . "world") ("sdf" . "paf")) () () () () () () () () () () ())

4.  Looking a Bruno Haible's paper[0] on this topic, it seems that getting
    it right is, well, pretty hard.  ;-)

> Why are you storing SCM references as properties?  It's more efficient 
>   both in time and space to use a SCM member in my_object_t.

That's the whole point of the test: object properties are used because
they involve weak hash tables.

Thanks,
Ludovic.

[0] http://www.haible.de/bruno/papers/cs/weak/WeakDatastructures-writeup.html


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2005-11-09 16:28 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-08 17:22 [PATCH] Marking weak alist vectors Ludovic Courtès
2005-11-08 23:51 ` Marius Vollmer
2005-11-09  9:03   ` Ludovic Courtès
2005-12-06 23:55     ` Marius Vollmer
2005-12-07 10:33       ` Ludovic Courtès
2005-12-13 23:45         ` Marius Vollmer
2005-12-14  9:30           ` Ludovic Courtès
2005-11-09 10:28 ` Han-Wen Nienhuys
2005-11-09 16:28   ` Ludovic Courtès [this message]
2005-11-09 18:36     ` Han-Wen Nienhuys
2005-11-09 21:11     ` Kevin Ryde
2005-11-09 22:45       ` Marius Vollmer
2005-11-10 12:11         ` Han-Wen Nienhuys
2005-11-10  9:47       ` [PATCH] Reference leak in `iprin1 ()' Ludovic Courtès
2005-11-12  9:23         ` Neil Jerram
2005-11-14  9:58           ` Ludovic Courtès
2005-11-16 21:18             ` Neil Jerram
2005-11-17  9:54               ` Ludovic Courtès
2005-11-17 18:52                 ` Neil Jerram
2005-11-23 10:19     ` [PATCH] Marking weak alist vectors, #2 Ludovic Courtès
2005-11-24  0:59       ` Han-Wen Nienhuys
2005-11-24  9:01         ` Ludovic Courtès
2005-11-26  0:49       ` Kevin Ryde
2006-01-09 14:51       ` [PATCH] Marking weak alist vectors, epilogue Ludovic Courtès
2006-01-09 19:29         ` Neil Jerram
2006-01-10  8:21           ` Ludovic Courtès
2006-01-10  9:33             ` Neil Jerram
2006-01-10 15:43               ` Ludovic Courtès
2005-11-17 13:21 ` [PATCH] Fixing `gc-live-object-stats' Ludovic Courtès
2005-11-17 14:12   ` Han-Wen Nienhuys
2005-11-30  8:54   ` Ludovic Courtès
2005-11-30 23:45     ` Han-Wen Nienhuys
2005-12-03 19:31       ` Neil Jerram
2005-12-05  8:50         ` Ludovic Courtès
2005-12-06 19:14           ` Neil Jerram

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=87y83xkcq6.fsf@laas.fr \
    --to=ludovic.courtes@laas.fr \
    --cc=guile-devel@gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).