From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludovic.courtes@laas.fr (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Marking weak alist vectors Date: Wed, 09 Nov 2005 17:28:01 +0100 Organization: LAAS-CNRS Message-ID: <87y83xkcq6.fsf@laas.fr> References: <87y83z3vh5.fsf@laas.fr> <4371CF46.4010708@xs4all.nl> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1131555181 17493 80.91.229.2 (9 Nov 2005 16:53:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 9 Nov 2005 16:53:01 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Nov 09 17:53:00 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EZt3m-0002ic-QB for guile-devel@m.gmane.org; Wed, 09 Nov 2005 17:44:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EZt3l-00066y-Tf for guile-devel@m.gmane.org; Wed, 09 Nov 2005 11:44:29 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EZsoG-00061K-BY for guile-devel@gnu.org; Wed, 09 Nov 2005 11:28:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EZsoF-00060Z-83 for guile-devel@gnu.org; Wed, 09 Nov 2005 11:28:27 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EZsoE-00060O-UG for guile-devel@gnu.org; Wed, 09 Nov 2005 11:28:26 -0500 Original-Received: from [140.93.0.15] (helo=laas.laas.fr) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1EZsoE-0007V5-OS for guile-devel@gnu.org; Wed, 09 Nov 2005 11:28:27 -0500 Original-Received: by laas.laas.fr (8.13.1/8.13.4) with SMTP id jA9GSOGd018724; Wed, 9 Nov 2005 17:28:25 +0100 (CET) Original-To: Han-Wen Nienhuys X-URL: http://www.laas.fr/~lcourtes/ X-Revolutionary-Date: 19 Brumaire an 214 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEB1F5364 X-PGP-Key: http://www.laas.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: powerpc-unknown-linux-gnu Mail-Followup-To: Han-Wen Nienhuys , guile-devel@gnu.org In-Reply-To: <4371CF46.4010708@xs4all.nl> (Han-Wen Nienhuys's message of "Wed, 09 Nov 2005 11:28:22 +0100") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) X-Spam-Score: 0 () X-Scanned-By: MIMEDefang at CNRS-LAAS X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:5383 Archived-At: Han-Wen Nienhuys 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