Weak sets keep growing

  • Open
  • quality assurance status badge
Details
One participant
  • Ludovic Courtès
Owner
unassigned
Submitted by
Ludovic Courtès
Severity
important
L
L
Ludovic Courtès wrote on 23 Mar 2020 15:17
(address . bug-Guile@gnu.org)
87h7yfqho5.fsf@gnu.org
Hello,

Consider this code:

Toggle snippet (13 lines)
(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))))

(You need to have the ‘%symbols’ procedure from libguile/symbols.c
compiled in.)

In 3.0.1+, it prints:

Toggle snippet (21 lines)
;;; (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>)

The size of the weak set keeps growing, even when GC happens.

Conversely, weak tables shrink upon GC.

Ludo’.
L
L
Ludovic Courtès wrote on 23 Mar 2020 22:57
(address . 40194@debbugs.gnu.org)
87y2rqpwdu.fsf@gnu.org
Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (2 lines)
> The size of the weak set keeps growing, even when GC happens.

Commit 02e3dc6ab95fe51786b68a8200322e163f8da478 mostly addresses it:

Toggle snippet (23 lines)
$ ./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>)

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’.
L
L
Ludovic Courtès wrote on 26 Apr 2020 19:13
control message for bug #40194
(address . control@debbugs.gnu.org)
87imhm187w.fsf@gnu.org
severity 40194 important
quit
?