[MLton-devel] Re: SML Basis review

Matthew Fluet fluet@cs.cornell.edu
Mon, 18 Aug 2003 15:03:13 -0400 (EDT)


BTW, the context of this is Chapter 8 of the SML Basis.  Under a section
titled "Comparision of I/O functions" there is a statement:

 * Stream I/O input is more efficient than Imperative I/O input.  At the
   least, the latter will require an extra indirection and assigment per
   operation.

I commented:

This is not necessarily true.  Both PolyML and MLton provide a "direct"
imperative buffered I/O layer so long as the underlying stream is not
extracted.  This can be significantly more efficient than the
ref StreamIO.instream  version.

On Mon, 18 Aug 2003, Matthew Fluet wrote:

> > Concerning the comparison of Imperative vs. Stream I/O input in MLton and
> > PolyML, are you saying that
> >
> >   Imperative I/O is faster than Stream I/O
> >
> > or that
> >
> >   Imperative I/O is no slower than Stream I/O
> >
> > assuming, of course, the underlying stream is not extracted?
>
> The former: Imperative I/O is faster than Stream I/O, assuming that the
> underlying stream is not extracted.
>
> Note that which input function one uses impacts how great the difference.
> The extreme example is input1: Under Stream IO, each input generates a
> large data structure (relative to the 1 byte that was returned)
> corresponding to the stream advanced by one byte.  This results in more
> allocation time, more GCs, etc.  Under the Buffered I (i.e., the special
> case of the Imperative IO), we simply update an integer ref corresponding
> to the current position in an array of buffered input.
>
> I have a slew of benchmarks that perform a line count on a file using each
> of the ImperativeIO and StreamIO input functions, comparing with and
> without forcing the underlying stream, and using various implementations.
> I could run them again if anyone wants hard numbers.
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites including
> Data Reports, E-commerce, Portals, and Forums are available now.
> Download today and enter to win an XBOX or Visual Studio .NET.
> http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
> _______________________________________________
> MLton-devel mailing list
> MLton-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mlton-devel
>



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel