[Ecls-list] make_stream_from_fd - buffering modes?

Juan Jose Garcia Ripoll lisp at arrakis.es
Tue Apr 25 05:43:10 UTC 2006


On Sun, 2006-04-23 at 11:26 -0700, daniel jay macdonald wrote:
> I was trying to use slime noticed that the output stream is not 
> buffered, causing my compiles to be about 10x slower than normal. The 
> problem appears to be in ecl_make_stream_from_fd:
> 
> ...
>     setbuf(fp, NULL);
> #if !defined(GBC_BOEHM)
>     setbuf(fp, NULL);
>     setbuf(fp, stream->stream.buffer = cl_alloc_atomic(BUFSIZ));
> #endif
> ...
> 
> I interpret this to mean that without boehm-gc I would get buffered 
> output. Is there a deep reason this cant be done with the boehm-gc 
> enabled? I dont feel comfortable hacking this since GBC_BOEHM seems to 
> exclude stream.buffer even being defined.

No, not really. The point is that ECL's own garbage collector needs to
keep track of the buffer and hence it is stored in a separate variable
-- if we do not do so, then we would need to deal with the internals of
the FILE structure, which is not portable.

The Boehm-Weiser garbage collector does not require this fix, because it
scans the content of all variables. Now, I do not explicitely set the
buffer of files because I assumed files are buffered by default.
According to GNU libc's manual:

   "Newly opened streams are normally fully buffered, with one
exception: a stream connected to an interactive device such as a
terminal is initially line buffered."

The problem is that the line setbuf(fp,NULL) above the #ifdef should not
be there. I have made several changes in ECL in order to allow changing
the buffering mode of an ordinary stream. Sockets can now be created
with a :BUFFERING-MODE option. Perhaps you should try rebuilding ECL
from CVS and using Slime with the following untested patch:

Index: swank-ecl.lisp
===================================================================
RCS file: /project/slime/cvsroot/slime/swank-ecl.lisp,v
retrieving revision 1.5
diff -u -u -r1.5 swank-ecl.lisp
--- swank-ecl.lisp      22 Mar 2006 16:40:01 -0000      1.5
+++ swank-ecl.lisp      25 Apr 2006 12:36:53 -0000
@@ -55,7 +55,8 @@
   (sb-bsd-sockets:socket-make-stream socket
                                      :output t
                                      :input t
-                                     :element-type 'base-char))
+                                     :element-type 'base-char
+                                     :buffering-mode :line-buffering))

 (defun accept (socket)
   "Like socket-accept, but retry on EAGAIN."


Regards,

Juanjo


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20060425/22ec5ca1/attachment.sig>


More information about the ecl-devel mailing list