Page 1 of 1

java performance

Posted: 10 Oct 2007, 18:05
by gringo
Hello, I was looking for information on how fast would be to program the games in Java using smart fox server rather than implementing a new 'smartfox like' program in order to be sure that I was fully using all the resources available of my servers.

My question was reduced to the following, I found a benchmark that the difference between Java and C++ was something like 'it takes 90 cycles in Java to do what takes C++ to do in 60'. So basically there is a difference but not big enough to justify the programming of a new system.

However, I've been told that Java uses JIT in latest versions in order to make the code faster. I would like to know if SmartFox uses this kind of approach for the extensions written in Java or if it runs in 'interpreted mode' such as using a VM or something like that.

The second doubt is:
I believe that if we choose to use Python for our games, it would make the games to run slower, because it is interpretated over Java if I understood it well, but did anybody do a test to know the exact relationship between Jython and Java pure code?

Thanks.

Posted: 11 Oct 2007, 07:20
by Lapo
My question was reduced to the following, I found a benchmark that the difference between Java and C++ was something like 'it takes 90 cycles in Java to do what takes C++ to do in 60'. So basically there is a difference but not big enough to justify the programming of a new system.
There are zillions of Java vs C/C#/C++ etc... benchmarks... in one Java is slower and in another it is faster ... if you tweak the VM you will beat the C code but if you tweak the C compiler (or use another one) you'll probably get better numbers and so forth... it's an endless story. :D Anyways, all I can say is that as of today the JVM is blazing fast.

We run a few specific server benchmarks recently with the latest JRE 1.6 and found that the overall performance is just amazing -> http://www.smartfoxserver.com/whitepapers/benchmarks/
I've been told that Java uses JIT in latest versions in order to make the code faster. I would like to know if SmartFox uses this kind of approach for the extensions written in Java or if it runs in 'interpreted mode' such as using a VM or something like that.
You definitely get JIT compilation!
I believe that if we choose to use Python for our games, it would make the games to run slower, because it is interpretated over Java if I understood it well, but did anybody do a test to know the exact relationship between Jython and Java pure code?
Of course there are important speed differences.
Have you ever tried running the same algorithm in C and Python? I think you get what I mean. ;)

The choice is up to you... IMHO today hardware is very affordable, so you can invest a little more money into that and cut down development times dramatically by using higher level languages ( as Python, Javascript etc... )

Additionally the choice depends a lot on which language you are more familiar with and what the code should do.
If your server side code is complex and cpu-intensive you can write the time-critical parts in Java and keep the rest of the code in Python

You get the best of both worlds :)

HTH

Posted: 12 Oct 2007, 18:06
by gringo
We have agreed to use Python for the games and porting CPU intensive classes to Java as you adviced. My main concern now is that I won't be able to use the nice and pretty debugger Flash CS3 has given me to quickly develop the games, since we will be adding them as an extension.

I didn't find any way to work on the game independently and using a simple client to test it without programming one in Python with pygame or something like that. Any advice for this one? (I hate trace)

Posted: 13 Oct 2007, 05:35
by Lapo
We have agreed to use Python for the games and porting CPU intensive classes to Java as you adviced. My main concern now is that I won't be able to use the nice and pretty debugger Flash CS3 has given me to quickly develop the games, since we will be adding them as an extension.
:shock:

It seems there's a misunderstanding going on... I was talking about the differences in developing the server side part of the game, not the client one. For the client part I am always referring to Flash / Flex
So if the client is developed in Flash you will of course be able to use the integrated debugger

Posted: 16 Oct 2007, 13:07
by gringo
I'm used to develop all the logic inside the clients. For the games I made, this worked ok because none of them required server side code.

I am going to start working on the server. To debug in the clients for me is very easy because (but not until to) Flash CS3 has good debugging tools that let me insert breakpoints, see the callstack and watch my variables.

It would be awesome to be able somehow to do the same thing with the logic I write in the server in Python, but as the code is being executed through smartfox I can't think on anything in order to do something similar to that. The only thing I could think of was to make some simple clients with PyGame and make a little game with the server integrated so that I can easily debug it and once I finish it, I could be able to take out the client and write it in Flash, now that I know that the server is completely finished.

However that would imply to write twice the client in two different languages and I wanted to know if somebody had thought of a more efficient method to do this. I would love to avoid using trace.

Posted: 17 Oct 2007, 06:17
by Lapo
Sounds like it's a pretty complicated way of debugging.

IMHO using a fine grained logging system is a much better system for debugging the server side part. Due to the multi-threaded asynchronous nature of multiplayer games it's usually much better to log all the relevant actions and params going in and out of the server, and then analyze what's going on.

Alternatively you can use the Eclipse debugger as explained by Potmo in this useful tutorial -> http://forums.smartfoxserver.com/viewtopic.php?t=1872

( this is more effective if you use Java as the extension language, but it's also possible to use it with Python )