output streams vs output ports Taylor Campbell (18 Jun 2005 00:26 UTC)
Re: output streams vs output ports Michael Sperber (18 Jun 2005 07:57 UTC)
Re: output streams vs output ports Taylor Campbell (18 Jun 2005 15:17 UTC)
Re: output streams vs output ports Michael Sperber (18 Jun 2005 18:51 UTC)
Re: output streams vs output ports Shiro Kawai (18 Jun 2005 21:06 UTC)
Re: output streams vs output ports Michael Sperber (19 Jun 2005 09:09 UTC)
Re: output streams vs output ports Shiro Kawai (19 Jun 2005 09:41 UTC)
Re: output streams vs output ports Michael Sperber (20 Jun 2005 05:41 UTC)
Re: output streams vs output ports Shiro Kawai (20 Jun 2005 09:16 UTC)
Re: output streams vs output ports Michael Sperber (21 Jun 2005 07:43 UTC)
Re: output streams vs output ports Shiro Kawai (21 Jun 2005 08:08 UTC)
Re: output streams vs output ports Michael Sperber (27 Jun 2005 05:45 UTC)

Re: output streams vs output ports Shiro Kawai 21 Jun 2005 08:07 UTC

>From: Michael Sperber <xxxxxx@informatik.uni-tuebingen.de>
Subject: Re: output streams vs output ports
Date: Tue, 21 Jun 2005 09:43:50 +0200

> Shiro Kawai <xxxxxx@lava.net> writes:
>
> > The simple-minded copy program:
[snip]
> > It runs 3.5x faster if I bypass locking of 'in' and 'out' ports
> > in Gauche.
>
> Could you selectively bypass the locking of only the input port so we
> get a better idea what the specific issue with the output port is?

Yes.  These are elapsed time for various conditions,
repeating the program 10 times.  System time was less than 10ms.

lock both         : 3.64s
lock output only  : 2.42s
lock input only   : 2.26s
no locking        : 1.04s

In the current implementation, a port has a recursive lock and
the pthread_mutex_lock is called when a builtin I/O procedure
is called and the calling thread hasn't acquired the lock.  So
the locking doesn't affect the large-granularity operation
such as read or write much, while it is expensive for fine-grained
operation such as read-char/write-char expensive.  Gauche
provides a procedure "with-port-locking" to lock the port in
larger granularity, which is what I used to "bypass" the
locking.

(Maybe I'm doing something stupid; if there's a clever way to
avoid this much of locking overhead, I'd like to be enlightened.)

--shiro