<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The idea that I currently like the most is to make it possible to save<br>
and load objects in the &quot;GHC heap format&quot;. That way, deserialisation<br>
could be done with a simple fread() and a fast pointer fixup pass,<br>
which would hopefully make running many &#39;ghc -c&#39; processes as fast as<br>
a single &#39;ghc --make&#39;. This trick is commonly employed in the games<br>
industry to speed-up load times [1]. Given that Haskell is a<br>
garbage-collected language, the implementation will be trickier than<br>
in C++ and will have to be done on the RTS level.<br>
<br>
Is this a good idea? How hard it would be to implement this optimisation?<br>
</blockquote>
<br></div></div>
I believe OCaml does something like this.<br></blockquote><div><br></div><div>Interesting.  What does OCaml do in this department?  A bit of googling didn&#39;t turn up a link.</div><div><br></div><div>For many years Chez scheme had a &quot;saved heaps&quot; capability.  It was recently dropped because of the preponderance of SE Linux which randomizes addresses and messes it up, but here&#39;s the doc for V7:</div>
<div><br></div><div>   <a href="http://www.scheme.com/csug7/use.html#g10">http://www.scheme.com/csug7/use.html#g10</a> </div><div><br></div><div>I&#39;ve always wondered why there weren&#39;t more language implementations with saved heaps.  Under Chez the startup times were amazing (a 50KLOC compiler a two second load would become 4 milleseconds).  Google Dart apparently has or will have saved heaps.  It seems like an obvious choice (caching initialized heaps) for enormous websites with slow load times like GMail.</div>
<div><br></div><div>Chez also has pretty fast serialization to a binary &quot;FASL&quot; (fast loading) format, but I&#39;m not sure if those were mmap&#39;ed into the heap on load or required some parsing.  The gamasutra link that Mikhail provided seems to describe a process where the programmer knows exactly what the expected heap representation is for a particular object is, and manually creates it.  Sounds like walking on thin ice.</div>
<div><br></div><div>Do we know of any memory safe GC&#39;d language implementations that can dump a single object (rather than the whole heap)?  Would invoke the GC in a special way to trace the structure and copy it into a new region (to make it contiguous)?</div>
<div><br></div><div>Cheers,</div><div>  -Ryan</div><div><br></div></div></div>