[Openmcl-devel] slow read-char

Gary Byers gb at clozure.com
Thu Jul 13 18:35:43 PDT 2006

My first guess would be locking, though I'm becoming an advocate of
saying "profile, don't guess."

If you're able to do WRITE-STRING "aaaaa...." instead of WRITE-CHAR,
should find that there's a lot less per-char overhead (including 
locking overhead.)

[The issue with locking the stream's buffer while modifying it has
less to do with making output look "orderly" somehow than it does
to do with avoiding corruption of the stream/buffer's internal state.
If that is indeed a big source of overhead - and I can imagine that
it could be - in WRITE-CHAR and if people really do I/O by repeated
calls to WRITE-CHAR - which might be a little harder to imagine, but 
there might be cases - then one way around some of that locking
overhead would be to introduce "thread-private streams", e.g.,
streams that can only be accessed by the thread that created them.]

On Fri, 14 Jul 2006, Takehiko Abe wrote:

> The following codes take longer to complete with OpenMCL 1.0
> than MCL 5.1:
> (with-open-file (out "home:test.temp"
>                     :direction :output
>                     :if-does-not-exist :create)
>  (dotimes (i 2097152)
>    (declare (fixnum i))
>    (write-char #\a out)))
> (with-open-file (in "home:test.temp")
>  (loop for char = (read-char in nil nil)
>        for c from 0
>        do
>        (unless char
>          (return c))))
> E.g. the latter form that calls read-char takes aprox 3.5
> times longer in my setup. It is as if no buffering takes
> effects.
> Does anyone have an idea what may cause the difference?
> Thanks.
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel

More information about the Openmcl-devel mailing list