From: JohnFredCee
Subject: SBCL/SLIME questions about core and I/O
Date: 
Message-ID: <1161332396.785713.113400@e3g2000cwe.googlegroups.com>
I'm using SBCL-0.9.17 and having a few problems, mostly due to my
newbieness, I suspect. Hopefully my newbieness will not prevent this
post from making sense, and the replies will elucidate a few points for
other newbies. Bear in mind that I'm using the non-threaded "out of the
box" build of SBCL..(which I imagine most newbies are).

Firstly, is it possible to save-lisp-and-die from the slime repl in
emacs and then restore later without the SWANK server causing errors on
startup? In other words what is the correct sequence of actions to dump
/ restart core when working with SBCL and slime? I used
(save-lisp-and-die #P"my.core") and   then sbcl --core my.core to
startup in anticipation of doing a slime-connect from Emacs, but that
gave me a lot of errors relating to SWANK and file descriptors (I'm
using fd handle communication because I'm using the non-threaded
build).

Secondly SBCL seems to hang when I print many forms: for instance when
iterating over a file line by line and printing the line - it seems to
get about 75% ot the way through a 3,000 line file, then hang, although
I can break and resume, so I assume it's stuck in a loop somewhere,
using 50% CPU as there is no HD activity. Does ~% in a format string
flush the streams or do I have to do it manually?

It's SBCL doing this and not Emacs comint mode as I tested at the REPL.
I'm using a non-threaded build, on Gentoo Linux. I'm going to try the
threaded build and see if my mileage changes. It must be something
local to my machine, right? No - one else is observing this behaviour?


John C.

From: Pascal Bourguignon
Subject: Re: SBCL/SLIME questions about core and I/O
Date: 
Message-ID: <87irif1hbp.fsf@thalassa.informatimago.com>
"JohnFredCee" <·····@yagc.ndo.co.uk> writes:

> I'm using SBCL-0.9.17 and having a few problems, mostly due to my
> newbieness, I suspect. Hopefully my newbieness will not prevent this
> post from making sense, and the replies will elucidate a few points for
> other newbies. Bear in mind that I'm using the non-threaded "out of the
> box" build of SBCL..(which I imagine most newbies are).
>
> Firstly, is it possible to save-lisp-and-die from the slime repl in
> emacs and then restore later without the SWANK server causing errors on
> startup? In other words what is the correct sequence of actions to dump
> / restart core when working with SBCL and slime? I used
> (save-lisp-and-die #P"my.core") and   then sbcl --core my.core to
> startup in anticipation of doing a slime-connect from Emacs, but that
> gave me a lot of errors relating to SWANK and file descriptors (I'm
> using fd handle communication because I'm using the non-threaded
> build).

You should build the core out of slime. 

You can load swank without starting it, then save the image.
Then when you load the image, there's no problem to start swank and
connect to it with slime.


I'd say it's something that should be debugged in swank.  Any
application should be prepared to deal gracefully with suddenly closed
sockets and file descriptors.


> Secondly SBCL seems to hang when I print many forms: for instance when
> iterating over a file line by line and printing the line - it seems to
> get about 75% ot the way through a 3,000 line file, then hang, although
> I can break and resume, so I assume it's stuck in a loop somewhere,
> using 50% CPU as there is no HD activity. 

I can't reproduce the behavior neither in 0.9.12 nor in 0.9.16.
(0.9.17 is not finished compiling).


> Does ~% in a format string
> flush the streams or do I have to do it manually?

Manually. FINISH-OUTPUT or FORCE-OUTPUT

> It's SBCL doing this and not Emacs comint mode as I tested at the REPL.
> I'm using a non-threaded build, on Gentoo Linux. I'm going to try the
> threaded build and see if my mileage changes. It must be something
> local to my machine, right? No - one else is observing this behaviour?
>
>
> John C.
>

* (time (with-open-file (out "/tmp/test.data" :direction :output
                            :if-does-not-exist :create :if-exists :supersede)
      (loop :with data = (loop :with data = (make-string 160)
                               :for i :from 0 :below 160
                               :do (setf (aref data i) 
                                         (code-char (+ 32 (mod i (- 127 32)))))
                               :finally (return data))
            :repeat 4000
            :for i :from 0
            :do (format out "~A~%" (subseq data (mod i 80)
                                                (+ 79 (mod i 80)))))))

Evaluation took:
  0.06 seconds of real time
  0.036002 seconds of user run time
  0.004001 seconds of system run time
  0 page faults and
  1,920,576 bytes consed.
NIL
* (time (prog1 nil (with-output-to-string (out)
           (with-open-file (inp "/tmp/test.data")  
              (loop :for line = (read-line inp nil nil) :while line
                    :do (format out "~A~%" line))))))

Evaluation took:
  0.099 seconds of real time
  0.080005 seconds of user run time
  0.012001 seconds of system run time
  0 page faults and
  6,709,240 bytes consed.
NIL
* (time  (with-open-file (inp "/tmp/test.data")
           (loop :for line = (read-line inp nil nil) :while line
                 :do (format t "~A~%" line))))
 !"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn
!"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno
"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnop
...

Evaluation took:
  5.971 seconds of real time
  0.004 seconds of user run time
  0.004 seconds of system run time
  0 page faults and
  1,934,816 bytes consed.
NIL
* (lisp-implementation-version)

"0.9.12"
* 





* (time (with-open-file (out "/tmp/test.data" :direction :output
                            :if-does-not-exist :create :if-exists :supersede)
      (loop :with data = (loop :with data = (make-string 160)
                               :for i :from 0 :below 160
                               :do (setf (aref data i) 
                                         (code-char (+ 32 (mod i (- 127 32)))))
                               :finally (return data))
            :repeat 4000
            :for i :from 0
            :do (format out "~A~%" (subseq data (mod i 80)
                                                (+ 79 (mod i 80)))))))
(time (with-open-file (out "/tmp/test.data" :direction :output
                            :if-does-not-exist :create :if-exists :supersede)
      (loop :with data = (loop :with data = (make-string 160)
                               :for i :from 0 :below 160
                               :do (setf (aref data i) 
                                         (code-char (+ 32 (mod i (- 127 32)))))
                               :finally (return data))
            :repeat 4000
            :for i :from 0
            :do (format out "~A~%" (subseq data (mod i 80)
                                                (+ 79 (mod i 80)))))))

Evaluation took:
  0.217 seconds of real time
  0.012001 seconds of user run time
  0.012 seconds of system run time
  0 page faults and
  1,921,696 bytes consed.
NIL
* (time (prog1 nil (with-output-to-string (out)
           (with-open-file (inp "/tmp/test.data")  
              (loop :for line = (read-line inp nil nil) :while line
                    :do (format out "~A~%" line))))))
(time (prog1 nil (with-output-to-string (out)
           (with-open-file (inp "/tmp/test.data")  
              (loop :for line = (read-line inp nil nil) :while line
                    :do (format out "~A~%" line))))))

Evaluation took:
  0.029 seconds of real time
  0.028002 seconds of user run time
  0.0 seconds of system run time
  0 page faults and
  6,704,192 bytes consed.
NIL
* (time  (with-open-file (inp "/tmp/test.data")
           (loop :for line = (read-line inp nil nil) :while line
                 :do (format t "~A~%" line))))
(time  (with-open-file (inp "/tmp/test.data")
           (loop :for line = (read-line inp nil nil) :while line
                 :do (format t "~A~%" line))))
 !"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn
!"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno
"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnop
...
Evaluation took:
  1.887 seconds of real time
  0.040003 seconds of user run time
  0.016001 seconds of system run time
  [Run times include 0.012 seconds GC run time.]
  0 page faults and
  1,934,992 bytes consed.
NIL
* (lisp-implementation-version)
(lisp-implementation-version)

"0.9.16"
* 
-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"What is this talk of "release"?  Klingons do not make software
"releases".  Our software "escapes" leaving a bloody trail of
designers and quality assurance people in its wake."
From: JohnFredCee
Subject: Re: SBCL/SLIME questions about core and I/O
Date: 
Message-ID: <1161336513.935674.280280@i42g2000cwa.googlegroups.com>
Pascal,

Many thanks for the comprehensive reply. I've tried my test file with
CMUCL (as I switched to it as I assumed this was an SBCL problem) and
it exhibits the same behaviour. It's stuck in a loop, continually
GC'ing. I'll post my code and files to reproduce thes later on (they
are on a laptop seperate from my main machine at the moment). I'm using
kernel 2.6.17-gentoo-r8 if that makes a difference. When I transfer the
files over, I'll give SBCL 0.9.17 for Win32 a test and see if it
happens there, too. If it doesn't, I'll assume it's a non-SBCL problem,
induced by something else in my setup..

John.

Pascal Bourguignon wrote:

> "JohnFredCee" <·····@yagc.ndo.co.uk> writes:
>
> > I'm using SBCL-0.9.17 and having a few problems, mostly due to my
> > newbieness, I suspect. Hopefully my newbieness will not prevent this
> > post from making sense, and the replies will elucidate a few points for
> > other newbies. Bear in mind that I'm using the non-threaded "out of the
> > box" build of SBCL..(which I imagine most newbies are).
> >
> > Firstly, is it possible to save-lisp-and-die from the slime repl in
> > emacs and then restore later without the SWANK server causing errors on
> > startup? In other words what is the correct sequence of actions to dump
> > / restart core when working with SBCL and slime? I used
> > (save-lisp-and-die #P"my.core") and   then sbcl --core my.core to
> > startup in anticipation of doing a slime-connect from Emacs, but that
> > gave me a lot of errors relating to SWANK and file descriptors (I'm
> > using fd handle communication because I'm using the non-threaded
> > build).
>
> You should build the core out of slime.
>
> You can load swank without starting it, then save the image.
> Then when you load the image, there's no problem to start swank and
> connect to it with slime.
>
>
> I'd say it's something that should be debugged in swank.  Any
> application should be prepared to deal gracefully with suddenly closed
> sockets and file descriptors.
>
>
> > Secondly SBCL seems to hang when I print many forms: for instance when
> > iterating over a file line by line and printing the line - it seems to
> > get about 75% ot the way through a 3,000 line file, then hang, although
> > I can break and resume, so I assume it's stuck in a loop somewhere,
> > using 50% CPU as there is no HD activity.
>
> I can't reproduce the behavior neither in 0.9.12 nor in 0.9.16.
> (0.9.17 is not finished compiling).
>
>
> > Does ~% in a format string
> > flush the streams or do I have to do it manually?
>
> Manually. FINISH-OUTPUT or FORCE-OUTPUT
>
> > It's SBCL doing this and not Emacs comint mode as I tested at the REPL.
> > I'm using a non-threaded build, on Gentoo Linux. I'm going to try the
> > threaded build and see if my mileage changes. It must be something
> > local to my machine, right? No - one else is observing this behaviour?
> >
> >
> > John C.
> >
>
> * (time (with-open-file (out "/tmp/test.data" :direction :output
>                             :if-does-not-exist :create :if-exists :supersede)
>       (loop :with data = (loop :with data = (make-string 160)
>                                :for i :from 0 :below 160
>                                :do (setf (aref data i)
>                                          (code-char (+ 32 (mod i (- 127 32)))))
>                                :finally (return data))
>             :repeat 4000
>             :for i :from 0
>             :do (format out "~A~%" (subseq data (mod i 80)
>                                                 (+ 79 (mod i 80)))))))
>
> Evaluation took:
>   0.06 seconds of real time
>   0.036002 seconds of user run time
>   0.004001 seconds of system run time
>   0 page faults and
>   1,920,576 bytes consed.
> NIL
> * (time (prog1 nil (with-output-to-string (out)
>            (with-open-file (inp "/tmp/test.data")
>               (loop :for line = (read-line inp nil nil) :while line
>                     :do (format out "~A~%" line))))))
>
> Evaluation took:
>   0.099 seconds of real time
>   0.080005 seconds of user run time
>   0.012001 seconds of system run time
>   0 page faults and
>   6,709,240 bytes consed.
> NIL
> * (time  (with-open-file (inp "/tmp/test.data")
>            (loop :for line = (read-line inp nil nil) :while line
>                  :do (format t "~A~%" line))))
>  !"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn
> !"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno
> "#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnop
> ...
>
> Evaluation took:
>   5.971 seconds of real time
>   0.004 seconds of user run time
>   0.004 seconds of system run time
>   0 page faults and
>   1,934,816 bytes consed.
> NIL
> * (lisp-implementation-version)
>
> "0.9.12"
> *
>
>
>
>
>
> * (time (with-open-file (out "/tmp/test.data" :direction :output
>                             :if-does-not-exist :create :if-exists :supersede)
>       (loop :with data = (loop :with data = (make-string 160)
>                                :for i :from 0 :below 160
>                                :do (setf (aref data i)
>                                          (code-char (+ 32 (mod i (- 127 32)))))
>                                :finally (return data))
>             :repeat 4000
>             :for i :from 0
>             :do (format out "~A~%" (subseq data (mod i 80)
>                                                 (+ 79 (mod i 80)))))))
> (time (with-open-file (out "/tmp/test.data" :direction :output
>                             :if-does-not-exist :create :if-exists :supersede)
>       (loop :with data = (loop :with data = (make-string 160)
>                                :for i :from 0 :below 160
>                                :do (setf (aref data i)
>                                          (code-char (+ 32 (mod i (- 127 32)))))
>                                :finally (return data))
>             :repeat 4000
>             :for i :from 0
>             :do (format out "~A~%" (subseq data (mod i 80)
>                                                 (+ 79 (mod i 80)))))))
>
> Evaluation took:
>   0.217 seconds of real time
>   0.012001 seconds of user run time
>   0.012 seconds of system run time
>   0 page faults and
>   1,921,696 bytes consed.
> NIL
> * (time (prog1 nil (with-output-to-string (out)
>            (with-open-file (inp "/tmp/test.data")
>               (loop :for line = (read-line inp nil nil) :while line
>                     :do (format out "~A~%" line))))))
> (time (prog1 nil (with-output-to-string (out)
>            (with-open-file (inp "/tmp/test.data")
>               (loop :for line = (read-line inp nil nil) :while line
>                     :do (format out "~A~%" line))))))
>
> Evaluation took:
>   0.029 seconds of real time
>   0.028002 seconds of user run time
>   0.0 seconds of system run time
>   0 page faults and
>   6,704,192 bytes consed.
> NIL
> * (time  (with-open-file (inp "/tmp/test.data")
>            (loop :for line = (read-line inp nil nil) :while line
>                  :do (format t "~A~%" line))))
> (time  (with-open-file (inp "/tmp/test.data")
>            (loop :for line = (read-line inp nil nil) :while line
>                  :do (format t "~A~%" line))))
>  !"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn
> !"#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno
> "#$%&'()*+,-./0123456789:;<=>·@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnop
> ...
> Evaluation took:
>   1.887 seconds of real time
>   0.040003 seconds of user run time
>   0.016001 seconds of system run time
>   [Run times include 0.012 seconds GC run time.]
>   0 page faults and
>   1,934,992 bytes consed.
> NIL
> * (lisp-implementation-version)
> (lisp-implementation-version)
>
> "0.9.16"
> *
> --
> __Pascal Bourguignon__                     http://www.informatimago.com/
>
> "What is this talk of "release"?  Klingons do not make software
> "releases".  Our software "escapes" leaving a bloody trail of
> designers and quality assurance people in its wake."