Active Topics

 


Reply
Thread Tools
Capt'n Corrupt's Avatar
Posts: 3,524 | Thanked: 2,958 times | Joined on Oct 2007 @ Delta Quadrant
#121
Originally Posted by attila77 View Post
It's bull****, pardon my language. I have yet to see a benchmark that does not fall into the trap of the author being more proficient with one language than the other, and therefore skewing the results by his 'stronger' language getting a bias.
Where is this obvious in the post?

The post links to academic papers, rather than pure anecdote.
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#122
Originally Posted by zimon View Post
Even with LLVM, you will suffer if you have used pointers in C++/C program. You just have to throw many of the optimization techniques down the drain when there is a pointer inside some basic block.
Again, these are the little 'a-ha !' type of rhetorical battles. You say that, I say yeah, but C++ can do stack allocations which eat Java's heap allocation for breakfast, what about casting... And so forth. Each platform has a set of "I do this better than the other one !" and that's why it's so difficult (=impossible) to do a proper comparison. It's like comparing whether car A is faster than car B, when A corners better and has better aerodynamics, but B has a stronger engine and better brakes. It will depend on the course, of course a.k.a. real life.

Originally Posted by Capt'n Corrupt View Post
Where is this obvious in the post?

The post links to academic papers, rather than pure anecdote.
Huh ? The guy explains fairly solidly in what way were the original C++ benchmarks inferior in terms of unoptimal code, i.e. things not done as one would if he was thinking with a 'C++ head' instead of just porting the Java code to C++.
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 
Capt'n Corrupt's Avatar
Posts: 3,524 | Thanked: 2,958 times | Joined on Oct 2007 @ Delta Quadrant
#123
Originally Posted by attila77 View Post
Huh ? The guy explains fairly solidly in what way were the original C++ benchmarks inferior in terms of unoptimal code, i.e. things not done as one would if he was thinking with a 'C++ head' instead of just porting the Java code to C++.
I was referring to the post that you replied to. I should have been more clear.

Another, good link explaining why interpreted code can be faster than fully compiled one, beside the two I already mentioned and which may be too technical and theoretic, is this:
http://scribblethink.org/Computer/javaCbenchmark.html
(It is kind of "old" also, but the facts haven't changed since then.)

Here is a relatively fresh benchmark test between Java and C++:
It's a tie!
It's bull****, pardon my language. I have yet to see a benchmark that does not fall into the trap of the author being more proficient with one language than the other, and therefore skewing the results by his 'stronger' language getting a bias. Or you know, realizing that there are different C++ compilers in the world. 3 years ago, most of my Java apps beat my C++ apps speedwise, simply because I knew a lot better how Java works and what is expensive. Nowadays, my C++ runs circles around my Java. So there, there is only one language benchmark that is worth more than a dime - real life.
My question is: where is "all into the trap of the author being more proficient with one language than the other, and therefore skewing the results by his 'stronger' language getting a bias" in the link?
 

The Following User Says Thank You to Capt'n Corrupt For This Useful Post:
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#124
Originally Posted by Capt'n Corrupt View Post
My question is: where is "all into the trap of the author being more proficient with one language than the other, and therefore skewing the results by his 'stronger' language getting a bias" in the link?
I don't see what your issue with that is... "I have yet to see" clearly said that this is my personal impression. It certainly is anecdotal as it draws on my Java/C++ sw developer experience, which has not been published in any IEEE proceedings, but that is exactly the reason why I case-in-point listed and linked information that goes to demonstrate that the original benchmark in question is indeed in no way conclusive.
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 

The Following User Says Thank You to attila77 For This Useful Post:
Capt'n Corrupt's Avatar
Posts: 3,524 | Thanked: 2,958 times | Joined on Oct 2007 @ Delta Quadrant
#125
Originally Posted by attila77 View Post
I don't see what your issue with that is... "I have yet to see" clearly said that this is my personal impression. It certainly is anecdotal as it draws on my Java/C++ sw developer experience, which has not been published in any IEEE proceedings, but that is exactly the reason why I case-in-point listed and linked information that goes to demonstrate that the original benchmark in question is indeed in no way conclusive.
No issue. I understand. I'm generally curious, and I apologize if it comes across as 'attacking'.. Trust me, it is not so. It's gotten me into trouble before.

I try to keep an open mind, though every now and then I have to check myself when I realize I'm falling into bias.
 

The Following User Says Thank You to Capt'n Corrupt For This Useful Post:
Posts: 1,341 | Thanked: 708 times | Joined on Feb 2010
#126
Originally Posted by attila77 View Post
Again, these are the little 'a-ha !' type of rhetorical battles. You say that, I say yeah, but C++ can do stack allocations which eat Java's heap allocation for breakfast, what about casting... And so forth. Each platform has a set of "I do this better than the other one !" and that's why it's so difficult (=impossible) to do a proper comparison.
Java VM can use stack allocations also when it sees they can be used. It even can use register allocations there where C++-compiler couldn't (because, yes, pointers in the basic block)
I believe Sun's Hotspot VM already had that feature.
 
Posts: 303 | Thanked: 146 times | Joined on Aug 2009
#127
Originally Posted by Capt'n Corrupt View Post
But I'm not talking about future potential or speed comparisons. What I *am* implying is that there are many factors (eg. cultural) that stand in the way of development using VM. In the case of game development, game developers seem to love C++. And in my experience the most vocal of developers loath change.
I am a game developer (although lately I work at the server part, not the client part). And there is now ay in hell I would write my games in Java.
Quake2 was ported to C# (which is the same thing as Java for the purpose discussed in this thread).
The performance is only 85% of the native code: http://www.codeproject.com/KB/mcpp/quake2.aspx
Would I like to lose 15% of the speed and make the code not portable on platforms that don't support it? Hell, no. C/C++ runs on pretty much any CPU ever made. .NET/JAVA/MONO don't.

But fast games *can* be coded in VM environments (see below). Hell even fast fully 3D games (w/ shaders) can be coded using Javascript (case and point: google's O3D). This was also before many of the fast optimizations to V8 (eg native compilation).
Sure they can. Heavy use of shaders will of course make the Java and C versions run at similar speeds, so long as you don't have a lot of non graphic code. But if you need to do stuff like physics, AI, etc. then the C/C++ version will be clearly faster.

1) the latest Dalvik implementation compiles often used traces into native code with little memory penalty -- ~96-98% computed cycles are native including jumps at around 80KB memory penalty; put another way, very little time is actually spent in the interpreter and the memory consumption is negligible.
So then why are many libs still written in native code? Why not just write everything in Java, including the kernel and stuff, if Java is so magic?

2) GC is largely controllable by the developer -- don't allocate new objects/temporary objects -- also, I think in Android the collector can be triggered by the developer (could be wrong). Bottom line, optimization is still a very active process regardless of the environment.
Scanning the memory for dead pointers is slower than manually deallocating the unused memory, no?

3) Core libraries are natively compiled and VM code (JIT or interpreted) simply calls them.
Why? If Java is so fast, why bother writing stuff in native code?

These are available today. I'm not saying that these optimizations are faster than native. What I *am* saying is that they are fast enough for most tasks -- even the intensive ones: games.
As a game developer, I can tell you that there is no such thing as "fast enough". There are always new things that can be implemented if you have spare CPU power.

As the JIT trace compile optimizations become more mature, this will improve still, and I suspect the differences between compiled C/C++ and .dex to be negligible.
C/C++ compilers also mature and can generate better code. And you can, of course, use profilers manually and fine tune the code in better ways than a VM can.

Bottom line? In this test, non-recursive code is as fast as native compiled code. Recursive is another story altogether, but again, recursive code can be unrolled in the optimization step of development.
The sample rate is too small, you'd probably execute that code even in QBasic in 0 ms I would like to see it repeated with larger numbers.
 

The Following User Says Thank You to Radu For This Useful Post:
Capt'n Corrupt's Avatar
Posts: 3,524 | Thanked: 2,958 times | Joined on Oct 2007 @ Delta Quadrant
#128
@Radu,

See, this is the problem pointed out in the paper that was linked. Programmers seem to cling to this notion that Java is slow and avoid it on this characteristic alone. Surely there are mechanisms/calls in Java that are slow, but the Java class is compiled, as is C/C++ code via a JIT, and this resultant native code, is every bit as fast as C/C++ and faster in some cases.

Here's an Quake 2 Java port example to counter your C# port example:
http://www.bytonic.de/html/benchmarks.html

What does this show? That the Windows JVM version (and only JRE 1.5) is actually faster than the HIGHLY tuned C version (remember, this is Carmack's software we're talking about) with the Windows JVM intepreter. Full-screen and the linux JVM are slower, but not by much.

This is anecdotal, as are your replies, and is in no way concrete. It does indicate, however, that at least in one case (to add to the others posted) it is very possible to write fast Java.

When you have genuine statistics that the Android Dalvik VM is only spending 2%-4% of the time interpreting instructions, the rest is native, the conclusion must be drawn that Dalvik is very, very fast.
http://www.youtube.com/watch?v=Ls0tM-c4Vfo

But I can see there is no way to convince you that Java has come a long way and is very fast. I am ok with this.

To answer some other questions:

Yes, GC can be slow. Don't use it. In java, with large enough heap, it's as fast as malloc. But with a small heap, the performance degrades.
http://www.cs.umass.edu/~emery/pubs/gcvsmalloc.pdf

I'd be very interested to see a kernel module in Java (DalvikVM for its lower memory requirements). I really would. There would be some interesting problems to overcome, but interesting problems yield interesting solutions.

Oh, and a good tradeoff for slightly lower performance could be a much larger market for your game. I still believe that with a bit of optimization, the performance gap would be negligible if any.
 
Capt'n Corrupt's Avatar
Posts: 3,524 | Thanked: 2,958 times | Joined on Oct 2007 @ Delta Quadrant
#129
I just want to add that the Dalvik VM JIT is only v1.0, and there are many further optimizations in the pipe:
  • inlining of methods for better tracing
  • trace extensions for better loop detection
  • JITing when not in app
  • storing traces persistently to avoid JITing with each run
  • general tuning
  • etc

It really is an exciting project! Portability and speed is a potent mix.

On another topic:
Just as the *blazing* fast V8 javascript engine (yes, also native compiled) has begun to find it's way into the server-script realm. I expect Dalvik will as well as a general development environment. It's certainly fast enough and its lower memory requirements make it attractive relative to JavaVM.
 
Posts: 376 | Thanked: 511 times | Joined on Aug 2009 @ Greece
#130
I believe the debate regarding which language is faster is moot for another reason:

The run time almost never outperforms the development time (and other benefits) when one considers which language/tool to use. For example:
  • Qt and GTK are insanely slow when compared with other widget toolkits but they are used because they are more complete and ease the development.
  • Using the "faster language" theory, everyone should write web apps using C and CGIs instead of PHP (and even java).
  • Most programs/products follow the "release early" and perhaps the "release often" idea instead of the "release a perfect product that is very very fast".
  • There is no reason to choose language X if it is faster when there are no developers using it out there. Who will code the program?

Thus, I highly doubt that the speed of a language will ever affect the initial product/OS adoption. Instead, the support and the abilities will do. That's why I was talking about the 'initial' release.

Also, as a personal opinion, speed is not everything. Better provide more that provide less and make them faster. You can only compare two existing products for speed. Not one that exists and it is slow and one that doesn't exist and it would be faster if it was ever written. Android already has a ton of apps and mobile phone manufacturers can instantly take advantage of them. No manufacturer (or human) currently cares if the apps in android's app store are slow.
 

The Following 2 Users Say Thank You to v13 For This Useful Post:
Reply

Tags
bada rox, dalvik, future, java haters, meego, meego?fail, nokia, sandbox sucks


 
Forum Jump


All times are GMT. The time now is 14:07.