[MLton-devel] Basis2002: IO
Matthew Fluet
fluet@CS.Cornell.EDU
Sat, 26 Oct 2002 16:11:45 -0400 (EDT)
I pushed through a FastImperativeIO functor that takes a BufferI (a new
structure encapsulating the functionality of a StreamIO but with
destructive update to an input array) and a StreamIO and uses BufferI
when the underlying stream is never extracted. This is essentially the
bin-or-text-io.fun method, except the BufferI coordinates with a
PrimIO.reader (just like StreamIO does), which provides a way of passing
around all the necessary system call stuff (i.e., reading, closeing,
seeking, etc.). So now I get:
MLton0 -- mlton.cvs.basis-1997
MLton1 -- mlton.cvs.basis-2002
run time ratio
benchmark MLton1
wc-input1 2.50
which is much better, but not quite on par with what was the before. I
think I just figured out where the overhead is. Posix.IO is supposed to
supply mk{Bin,Text}{Reader,Writer} functions for creating
{Text,Bin}PrimIO.{reader,writer}s from file descriptors. I adapted some
SML/NJ code for this (appropriately cited). The big problem right now is
that I make the mkTextReader from the mkBinReader by
Primitive.String.fromWord8Vector-ing the vectors returned by readVec and
readVecNB. Unfortunately, a lot of the BufferI is using readArr and
readArrNB, which can be synthesized from readVec and readVec by
TextPrimIO.augment_reader, but at the cost of copying from the vector into
the array. That would explain the really high time in a loop copying from
a vector into an array. If I can produce a "native" readArr and readArrNB
for Text (which shouldn't be too hard, it's just getting the types to work
out; at worst, I'll just make another Posix _ffi that is cast with the
right type), then I think we'll recover another big gain.
I haven't touched the StreamIO stuff, so that is unchanged.
-------------------------------------------------------
This SF.net email is sponsored by: ApacheCon, November 18-21 in
Las Vegas (supported by COMDEX), the only Apache event to be
fully supported by the ASF. http://www.apachecon.com
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel