Philip Clayton wrote:
I have found a performance issue when using TextIO.StreamIO.input1 to read a functional stream. Looking at gc/non-gc times and using PolyML.profiling, it appears that garbage collection accounts for most of the time. There is some code below to demonstrate with stats that include comparison with SML/NJ.
The profiling shows that readFromReader in basis/BasicStreamIO.sml is responsible for creating values that are being garbage collected. Looking at this code, I can see various things that would contribute to this garbage collection but nothing that is obviously problematic. Is it simply the case that overheads in the implementation mean that it is not suitable for a large number of small reads?
I've finished redoing the functional IO code and I think I've eliminated most of the inefficiencies. The new version is now in CVS. Could you rerun your tests and let me know if it all works satisfactorily?
The new version is actually faster than using TextIO.input1 because TextIO.input1 has to lock a mutex to be thread-safe whereas TextIO.StreamIO.input1, being functional, only needs to lock a mutex when reading a block.
David