Lawrence Kirby wrote:
I don't think that comparing against a C compiler that may be producing very poor code proves much.
True. You'll note I limited my claims. However, when some machines free up, I can make the same comparision against better compilers. Or, maybe, just look up some old results in my office tomorrow.
While I picked a combination most suitable to make the point, it happened to be the machine that wasn't tied up with other things and in a situation with only the one compiler available.
For all the caveats, it is an existence proof that says a 2-to-1 deficit isn't inevitable. Moreover, while the compiler is a bit suspect, it did have good optimization levels turned on. This wasn't against a -g binary.
Even with better compilers, I don't expect to see a 2-to-1 deficit, though FFT might be one of the few remaining such cases. Java may not win, in other words, but I expect it will show up well.
When you compile for a DC project you try to use the best compiler available.
But not everyone knows how to set the compiler options to best advantage. Some people even have folk beliefs like "setting optimization above -O2 risks bad code" and they won't do -O3, much less evaluate -floop_unroll and like things. On modern machines, an excellent compiler with the best compiler optimizations backed off is not going to overwhelm Java.
I see this sort of thing all the time in my job. I don't believe you can assume every SETI port has optimal compiler settings for the highest optimization that could be gotten away with. Ditto other DC projects.
Sometimes small code generation problems can produce huge performance hits. For example when using double precision floating point on PIII and similar processors if the memory access isn't 8 byte aligned the access overhead is truely horrendous. Some compilers and allocations libraries only align to 4 byte boundaries.
I don't know of any compiler and malloc combination that is making that particular mistake today. This has been an issue for at least three years and more, so there's been a transition. Most mallocs now round to an eight byte boundary "just in case" doubles are used in the data structure somewhere. In fact, no malloc available to me does otherwise and I have access to several over several 32 bit platforms. And, the compilers align things intelligently too, for the most part.
Usually, to get bad alignment today, you have to use #pragmas or something. Java, by the way, will not have unaligned data references. Due to its nature, there is no byte-by-byte sequence guarantee for class files as there can be for structs in C and there is no pragma for force "packing" of data. It can do whatever it needs to so that the data is aligned, including reorder fields or add pad bytes. This is one advantage of a pointer-free language.
However, I take your broader point. This may be particularly relevant to SETI in particular since it spends a lot of time in a small bit of code or a small couple of bits of code. There are other applications in the world with such behavior and so the ratio between any two languages (even C++ and C) could hang on some vary narrow details in any particular case. That's one reason my presentations to customers contain lawyer-approved caveats.
Still, if one looks broadly at a suite of programs, it is hard to conclude that 2-to-1 results will be typical, which means, even for applications with a few tight loops, many of them will show a deficit well under 2-to-1, even against a good C/C++ compiler. A few cases will even show Java winning.