[MLton-devel] size of closures

Stephen Weeks MLton@mlton.org
Wed, 22 Jan 2003 11:32:37 -0800


> I reworked the StreamIO functor to cut down on allocation.  I finally got
> it on par with the existing IO (yeah!), but then I went back to clean up
> some code, and I ended up blowing up the size by quite a bit. 
...
> Now, at first I had this version of input1:
...
> scanStream          0.0%          (0)  54.8% (30,485,760) 0.0%     (0)
> input1              0.0%          (0)  54.8% (30,481,920) 0.0%     (0)
...
> Now, I change input1 to the following, which I thought was a little
> cleaner:
...
> scanStream         47.3% (480,000,480)  97.5%   (990,486,240) 0.0%      (0)
> input1             47.3% (480,000,000)  50.3%   (510,481,920) 0.0%      (0)
...
> I'm also a bit concerned about the fact that scanStream's cur
> allocation increased, since I only modified input1.

I looked into this and it is not a profiling bug, or any other kind of
bug.  It is simply a weirdness of how optimization happens. The extra
closures that get created within input1 are both closed over the input
stream, "is".  Because it has to be stored in those closures, "is" is
now allocated each time arround the scanStream loop, instead of being
flattened.


-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel