|
After exactly a month, since we have created generics branch, the Nemerle compiler finally can compile itself generating working generic code. It was harder than we initially thought due to numerous issues in both Mono and MS.NET runtimes. Mono had more issues, but the feedback loop was much shorter, Martin was very quick to fix problems we have found, thank you! #75429 was the last one preventing full bootstrap.
I was somewhat disappointed by poor performance of the generic code. Nemerle uses a lot of generic containers and switching from cast-everything-to-object (type erasure) to real generic code brought us about 10x slowdown. On small example (the standard library) the non-generic code uses 6.4s vs 50s, on a larger one (the main compiler library) it is 41s vs 405s. This is all on amd64 (1.8Ghz).
We will be doing some micro benchmarks shortly, but as I understand it today mono creates a separate copy of machine code for each instantiation of generic type or generic method. Which seems to be a problem with heavily polymorphic code, like the one we use.
But hey, it works! :-)
From: Martin Baulig (84.58.29.172)
<p>One very big outstanding task (which'll probably take a week or two to implement) is <b>shared code</b>.
<p>Shared code means that if you have two instantiations of the same generic type with reference types, all methods in that generic instance are only JITed once and then reused. This also implies that things must only be inflated once etc.
<p>The current performance problem comes from the fact that the current generics code does a lot of expensive operations which still have to be optimized away - the main performance adantage in using generics is avoiding casts - and we're not doing this internally yet.
From: Martin Baulig (84.58.29.172)
Ok, looks like I can't use HTML here ;-)