* bug#40194: Weak sets keep growing
@ 2020-03-23 14:17 Ludovic Courtès
2020-03-23 21:57 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Ludovic Courtès @ 2020-03-23 14:17 UTC (permalink / raw)
To: bug-Guile
Hello,
Consider this code:
--8<---------------cut here---------------start------------->8---
(define (create-symbols)
(let loop ((i 10000))
(unless (zero? i)
(gensym)
(loop (1- i)))))
(let loop ((i 10))
(unless (zero? i)
(pk i (%symbols))
(create-symbols)
(loop (1- i))))
--8<---------------cut here---------------end--------------->8---
(You need to have the ‘%symbols’ procedure from libguile/symbols.c
compiled in.)
In 3.0.1+, it prints:
--8<---------------cut here---------------start------------->8---
;;; (10 #<weak-set 3517/7027>)
;;; (9 #<weak-set 10271/14051>)
;;; (8 #<weak-set 11625/28099>)
;;; (7 #<weak-set 21625/28099>)
;;; (6 #<weak-set 11090/56197>)
;;; (5 #<weak-set 21090/56197>)
;;; (4 #<weak-set 31090/56197>)
;;; (3 #<weak-set 41090/56197>)
;;; (2 #<weak-set 5052/112363>)
;;; (1 #<weak-set 15052/112363>)
--8<---------------cut here---------------end--------------->8---
The size of the weak set keeps growing, even when GC happens.
Conversely, weak tables shrink upon GC.
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#40194: Weak sets keep growing
2020-03-23 14:17 bug#40194: Weak sets keep growing Ludovic Courtès
@ 2020-03-23 21:57 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2020-03-23 21:57 UTC (permalink / raw)
To: 40194
Ludovic Courtès <ludo@gnu.org> skribis:
> The size of the weak set keeps growing, even when GC happens.
Commit 02e3dc6ab95fe51786b68a8200322e163f8da478 mostly addresses it:
--8<---------------cut here---------------start------------->8---
$ ./meta/guile -s ~/src/guile-debugging/weak-set-growth.scm
;;; (10 #<weak-set 3517/7027>)
;;; (9 #<weak-set 10271/14051>)
;;; (8 #<weak-set 11711/14051>)
;;; (7 #<weak-set 9895/14051>)
;;; (6 #<weak-set 7697/14051>)
;;; (5 #<weak-set 11559/14051>)
;;; (4 #<weak-set 9220/14051>)
;;; (3 #<weak-set 6833/14051>)
;;; (2 #<weak-set 10637/14051>)
;;; (1 #<weak-set 8232/14051>)
--8<---------------cut here---------------end--------------->8---
It turns out that the core issue is that ‘vacuum_all_weak_sets’ is only
ever called a couple of times at the beginning of the execution, and
that’s it.
So it seems that the trick of ‘scm_i_register_async_gc_callback’ no
longer works as expected.
Thoughts?
Incidentally, in the reproducer I posted, if you insert (gc) after
(create-symbols), then the weak set grows a bit more! Which makes me
wonder if we’re not leaking entries due to messed up disappearing links
or something.
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-23 21:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 14:17 bug#40194: Weak sets keep growing Ludovic Courtès
2020-03-23 21:57 ` Ludovic Courtès
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).