[MLton] runtime support for object sharing
Stephen Weeks
MLton@mlton.org
Mon, 4 Oct 2004 18:14:32 -0700
Runtime support for object sharing is now in place. There are no
known bugs. It is available via the MLton.share and MLton.shareAll
functions. You can also enable hash consing on every GC by calling an
executable with @MLton hash-cons -- (this is an undocumented switch).
Because hash consing is integrated with the mark phase of the
mark-compact GC, this will cause all major collections to use
mark-compact GC.
Please try it out.
I tested @MLton hash-cons -- on a self compile, and got a decent
improvement in max live data size (from 340M to 265M) with about a 12%
slowdown (from 565s to 634s). Here are more detailed numbers
Without hash consing:
MLton finished in 435.77 + 129.01 (23% GC)
GC type time ms number bytes bytes/sec
------------- ------- ------- --------------- ---------------
copying 20,700 21 1,085,640,572 52,446,404
mark-compact 34,050 3 605,057,112 17,769,664
max live: 340,815,648 bytes
With hash consing:
MLton finished in 431.25 + 202.98 (32% GC)
GC type time ms number bytes bytes/sec
------------- ------- ------- --------------- ---------------
copying 0 0 0 -
mark-compact 88,960 9 795,005,648 8,936,664
minor 112,240 228 3,510,683,916 31,278,366
max live: 265,584,652 bytes
As you can see, hash consing slows down mark-compact by about a factor
of two. Maybe using it selectively (say, every 10th gc) would give
most of the benefit without most of the cost.