Optimizing Compilers

If you are working in an area with a lot of deep theory (OptimizingCompilers, for example) then XP needs to be modified, at the very least. YAGNI assumes that you know the theory, and that you use it to tell whether you are going to need it. --RalphJohnson

I have all these math and computer science degrees, and I'm glad of it. But it seems like the only thing I actually use is my ability to think. OTOH, I don't write many optimizing compilers any more.

So I was wondering: when we look at the average large C program, and we test it with compiler optimization off and with it on, how much of the improvement comes from the deep theoretical optimizations , and how much from the obvious and easy temp-caching, local register optimization ones that we can all see how to do?

--RonJeffries

Part B might be: what percentage of code generation defects are optimization-related?

Related:


I was at a talk last month by James Gosling, in which he ticked off the compiler optimizations going into HotSpot. He wound up listing 17 or so recent PhD theses (on things like how locality of reference affects garbage collection algorithms etcetera) and concluded "It's pretty far along on the rocket-science scale."

Of course, I haven't seen the hot spot code. But if we take Sun's numbers as somewhat real AND we assume that the Symantec JIT is mostly doing the obvious stuff listed above (both reasonable assumptions, imho) then deep theoretical optimizations can give you orders of magnitude improvement.

WilliamGrosso

According to Sun's whitepaper on HotSpot, a lot of the difference between HotSpot and traditional JIT compilers is due to the fact that the traditional approaches don't get you that much in Java. With many of the traditional approaches, the more code you can work with, the more you can optimize it. But methods are typically small in Java. Moreover, most methods are dynamically linked, making inlining problematic. One of the HotSpot tricks is to use inlining anyway. The trick is that the compiler will undo and redo inlining when needed. --KielHodges

I'd like to see some apples and apples comparisons, like what does HotSpot do with optimizations on vs off. Comparing one compiler to another has too many other variables. --RonJeffries

I believe that so far the comparisons are apples to theoretical oranges! Does anyone know about any hard numbers on HotSpot? --KielHodges

There are no apples to apples comparisons. See

http://www.javalobby.org/fr/html/frm/javalobby/features/jpr/part1.html

And for more recent stuff, see:

http://www.developer.ibm.com/java/j2/j2perfpaper.html

IBM has the best virtual machines. That's not because they read theses on how to write them: they write the theses. They have several expert teams around the world. Sun's advantage is that they own Java. IBM just does it better. So, what does that say? And what does it say that the same virtual machine maestros got sideswiped by PocketSmalltalk? (I zinged them with that in the interview. ;) -- SunirShah


What I know relies on transitive trust. When EliotMiranda, head VM guy at (then) Parcplace-Digitalk, saw HotSpot at Oopsla97, his jaw dropped. He came back saying "Buy this, it's brilliant."

Compiler optimization is deep magic; I don't know enough to have an informed opinion. If Eliot (and the other compiler experts I know) thinks it's worthwhile, that's good enough for me. Your mileage may vary. --BetsyHanesPerry

I don't think Eliot would be fond of XpForOptimizingCompilers.


Everyone who does is under an NDA-- HotSpot is in deep alpha right now and, AFAIK, in very limited distribution.

The problem is: HotSpot is unlikely to have lots of configurability options-- Gosling stressed that programmers are really bad at spotting the bottlenecks beforehand (or knowing what optimizations are likely to provide a substantial performance boost). In which case, how do we answer RonJeffries's question ? -- WilliamGrosso

Are you serious? It seems that Java's entire premise is that JamesGosling is smarter than everyone else.


If you are seriously interested in bleeding edge optimizing compilers, and you want some real numbers to back up what you're seeing, check out the work going on at The University of Washington. Craig Chambers, Jeffrey Dean, David Grove (and others, probably). Good starting point is http://www.cs.washington.edu/research/projects/cecil/www/www/Papers/papers.html --AnthonyLander

The SelfLanguage Project is also worth a look, at http://self.smli.com/. There's a continuing stream of development that starts with Smalltalk, goes through Self and ends up at Cecil/Vortex. HotSpot is another offshoot. For sure, the Sun guys knew about this stuff before they designed Java. -- DaveHarris

There seems to be an implicit assumption here that Java was designed. Is there independent evidence of that? And what version of the Java spec is the one that was designed, and what are the others? ;->

IIRC, Java was originally meant to be a compiled language for consumer applicances. They first considered CeePlusPlus, but thought it too complex. -- StephanHouben

Java doesn't exist on computer appliances yet (after eight years). All the Java cellphones have been recalled or have died at market. What does that say?


"how locality of reference affects garbage collection algorithms"

Is this an argument against casting things in stone and code ownership? I gather a small change of language syntax or implementation can have profound effects on how efficient it can be made, and that these effects are hard to foretell. This is when we need XP most. -- DaveHarris


CategoryCompilers


EditText of this page (last edited December 17, 2004) or FindPage with title or text search