(gc :full t) has no effect under certain circumstances
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Hi,
$ sbcl --version
SBCL 1.0.57.0.debian
apt-cache policy sbcl
sbcl:
Installed: 2:1.0.57.0-1
Candidate: 2:1.0.57.0-1
Version table:
*** 2:1.0.57.0-1 0
100 /var/lib/
This is backported from the unstable sources, which for some reason
didn't build on the Debian servers, so currently there isn't a version
of this in unstable.
CL-USER> *FEATURES*
(CFFI-FEATURES:
CFFI-SYS:
:ASDF-UNICODE :X86 :UNIX :ELF :LINUX :LARGEFILE :GENCGC
:STACK-
:COMPARE-
:STACK-
:STACK-
:CYCLE-COUNTER :INLINE-CONSTANTS :MEMORY-
:LINKAGE-TABLE :LITTLE-ENDIAN :OS-PROVIDES-DLOPEN :OS-PROVIDES-DLADDR
:OS-PROVIDES-PUTWC :OS-PROVIDES-
:OS-PROVIDES-POLL :IEEE-FLOATING-
:SB-UNICODE :SB-PACKAGE-LOCKS :SB-LDB :SB-TEST :SB-DOC :SBCL :COMMON-LISP
:ANSI-CL :SB-CORE-
CL-USER>
$ uname -a
Linux orwell 2.6.32-
I hope the SBCL developers consider this is a bug, because I find this
quite worrying behavior.
I had earlier posted about the issue in the SBCL users mailing list;
see
http://
I found this apparently related SO question
http://
and the corresponding SBCL bug report.
https:/
So, consider the code below. If I run
(gibbs 10000 1000)
a few times, it quickly gets to the point where
(gc :full t)
doesn't have any effect. From the documentation, and from the above
question (and other places) it seems like this command should remove
all the garbage, and return the dynamic space usage of the system to a
state similar to newly started system.
In my case, I could do this with two calls. Here is the breakdown.
Starting SBCL in SLIME.
CL-USER> (room)
Dynamic space usage is: 52,418,208 bytes.
Read-only space usage is: 3,512 bytes.
Static space usage is: 2,224 bytes.
Control stack usage is: 5,928 bytes.
Binding stack usage is: 536 bytes.
Control and binding stack usage is for the current thread only.
Garbage collection is currently enabled.
Breakdown for dynamic space:
13,761,968 bytes for 312,044 instance objects.
11,280,888 bytes for 14,802 code objects.
8,596,016 bytes for 1,074,502 cons objects.
5,949,728 bytes for 108,096 simple-vector objects.
3,182,624 bytes for 23,271 simple-
9,940,888 bytes for 384,486 other objects.
52,712,112 bytes for 1,917,201 dynamic objects (space total.)
CL-USER> (time (gibbs 10000 1000))
Evaluation took:
11.412 seconds of real time
11.132697 seconds of total run time (10.708670 user, 0.424027 system)
[ Run times consist of 0.260 seconds GC time, and 10.873 seconds non-GC time. ]
97.56% CPU
22,931,017,211 processor cycles
960,000,232 bytes consed
NIL
CL-USER> (room)
Dynamic space usage is: 205,911,504 bytes.
Read-only space usage is: 3,512 bytes.
Static space usage is: 2,224 bytes.
Control stack usage is: 5,928 bytes.
Binding stack usage is: 536 bytes.
Control and binding stack usage is for the current thread only.
Garbage collection is currently enabled.
Breakdown for dynamic space:
160,000,024 bytes for 3 simple-
11,920,480 bytes for 15,835 code objects.
34,437,464 bytes for 1,584,980 other objects.
206,357,968 bytes for 1,600,818 dynamic objects (space total.)
; No value
CL-USER> (gc :full t)
NIL
CL-USER> (room)
Dynamic space usage is: 44,923,472 bytes.
Read-only space usage is: 3,512 bytes.
Static space usage is: 2,224 bytes.
Control stack usage is: 5,928 bytes.
Binding stack usage is: 536 bytes.
Control and binding stack usage is for the current thread only.
Garbage collection is currently enabled.
Breakdown for dynamic space:
11,920,288 bytes for 15,833 code objects.
9,031,992 bytes for 204,878 instance objects.
7,645,000 bytes for 955,625 cons objects.
5,258,768 bytes for 84,320 simple-vector objects.
2,717,856 bytes for 22,062 simple-
2,472,504 bytes for 18,261 simple-
6,097,944 bytes for 232,791 other objects.
45,144,352 bytes for 1,533,770 dynamic objects (space total.)
; No value
So, the GC collector can deal with one run. Now two runs.
CL-USER> (time (gibbs 10000 1000))
Evaluation took:
10.556 seconds of real time
10.372648 seconds of total run time (10.076630 user, 0.296018 system)
[ Run times consist of 0.092 seconds GC time, and 10.281 seconds non-GC time. ]
98.27% CPU
21,210,966,230 processor cycles
959,997,968 bytes consed
NIL
CL-USER> (time (gibbs 10000 1000))
Evaluation took:
10.632 seconds of real time
10.612663 seconds of total run time (10.292643 user, 0.320020 system)
[ Run times consist of 0.100 seconds GC time, and 10.513 seconds non-GC time. ]
99.82% CPU
21,364,331,941 processor cycles
959,997,968 bytes consed
NIL
CL-USER> (room)
Dynamic space usage is: 333,458,656 bytes.
Read-only space usage is: 3,512 bytes.
Static space usage is: 2,224 bytes.
Control stack usage is: 5,928 bytes.
Binding stack usage is: 536 bytes.
Control and binding stack usage is for the current thread only.
Garbage collection is currently enabled.
Breakdown for dynamic space:
240,000,032 bytes for 4 simple-
48,337,280 bytes for 3,021,080 double-float objects.
45,948,400 bytes for 1,617,867 other objects.
334,285,712 bytes for 4,638,951 dynamic objects (space total.)
; No value
CL-USER> (gc :full t)
NIL
CL-USER> (room)
Dynamic space usage is: 204,782,320 bytes.
Read-only space usage is: 3,512 bytes.
Static space usage is: 2,224 bytes.
Control stack usage is: 5,928 bytes.
Binding stack usage is: 536 bytes.
Control and binding stack usage is for the current thread only.
Garbage collection is currently enabled.
Breakdown for dynamic space:
160,000,024 bytes for 3 simple-
11,920,288 bytes for 15,833 code objects.
33,304,480 bytes for 1,539,249 other objects.
205,224,792 bytes for 1,555,085 dynamic objects (space total.)
; No value
CL-USER> (gc :full t)
NIL
CL-USER> (room)
Dynamic space usage is: 124,779,480 bytes.
Read-only space usage is: 3,512 bytes.
Static space usage is: 2,224 bytes.
Control stack usage is: 5,928 bytes.
Binding stack usage is: 536 bytes.
Control and binding stack usage is for the current thread only.
Garbage collection is currently enabled.
Breakdown for dynamic space:
80,000,016 bytes for 2 simple-
11,920,288 bytes for 15,833 code objects.
9,025,952 bytes for 204,590 instance objects.
7,621,296 bytes for 952,662 cons objects.
16,432,264 bytes for 355,744 other objects.
124,999,816 bytes for 1,528,831 dynamic objects (space total.)
; No value
CL-USER> (gc :full t)
NIL
CL-USER> (room)
Dynamic space usage is: 124,792,128 bytes.
Read-only space usage is: 3,512 bytes.
Static space usage is: 2,224 bytes.
Control stack usage is: 5,928 bytes.
Binding stack usage is: 536 bytes.
Control and binding stack usage is for the current thread only.
Garbage collection is currently enabled.
Breakdown for dynamic space:
80,000,016 bytes for 2 simple-
11,920,288 bytes for 15,833 code objects.
9,026,480 bytes for 204,601 instance objects.
7,622,000 bytes for 952,750 cons objects.
16,648,616 bytes for 381,389 other objects.
125,217,400 bytes for 1,554,575 dynamic objects (space total.)
; No value
Running (gc :full t) more times has no effect on those 80 million bytes.
Note, I have the following in my .emacs
(setq slime-lisp-
So I am running SBCL with dynamic space size set to 1024Mb.
Running gibbs more times causes the gc to get stuck at higher levels
of garbage, but basically it's the same situation. Though I hardly
know anything about CL or garbage collection, this doesn't look good
to me.
#######
(eval-when (:compile-toplevel :load-toplevel :execute)
(require :cl-rmath) (setf *read-default-
(declaim (inline cl-rmath:rnorm cl-rmath:rgamma))
(cffi:defcfun ("rgamma" rgamma) :double
(arg0 :double)
(arg1 :double))
(cffi:defcfun ("rnorm" rnorm) :double
(arg0 :double)
(arg1 :double))
(defun gibbs (N thin)
(declare ((integer 0 #.most-
(declare (optimize (speed 3) (safety 1)))
(declare (optimize debug))
(let ((x 0.0) (y 0.0)
(xvec (make-array 10000000 :element-type '(double-float 0.0 *) :adjustable nil :fill-pointer nil :displaced-to nil))
(yvec (make-array 10000000 :element-type 'double-float :adjustable nil :fill-pointer nil :displaced-to nil)))
(declare (double-float x y))
(declare (type (simple-array (double-float 0.0 *) (10000000)) xvec))
(declare (type (simple-array double-float (10000000)) yvec))
(dotimes (i N)
(dotimes (j thin)
(setf xval (cl-rmath::rgamma 3.0 (/ 1 (+ (* yval yval) 4))))
(setf yval (cl-rmath::rnorm (/ 1 (+ xval 1)) (/ 1 (sqrt (+ (* 2 xval) 2)))))
(setf x xval)
(setf y yval))))))
(defun main (argv)
(declare (ignore argv))
(gibbs 10000 1000))
Changed in sbcl: | |
status: | Incomplete → Confirmed |
I don't have R installed here, so I'm using dummy definitions for RNORM and RGAMMA. (Note also that your CFFI definitions are in the wrong package -- unless you're missing an assumed IN-PACKAGE :CL-RMATH there.)
(declaim (inline rnorm rgamma))
(defun rnorm (x y)
(declare (double-float x y))
(* x y))
(defun rgamma (x y)
(declare (double-float x y))
(+ x y))
Given these, and running
(loop repeat 100
(write- line "---"))
do (gibbs 10000 1000)
(room)
(write-line "--- After full GC ---")
(gc :full t)
(room)
I could not reproduce your symptoms so far.
Can you reproduce your symptoms without using CL-RMATH? If so, please provide a full terminal (not Slime) session transcript.